Changeset 332

Show
Ignore:
Timestamp:
05/23/07 07:04:58 (2 years ago)
Author:
blackhedd
Message:

Moved network initialization from EventMachine_t::Run to EventMachine_t::EventMachine_t.
This fixes a bug. We were initializing loop breakers before initializing the network
library. The bug was masked because Ruby initializes the network library itself.
Thanks to Bill Kelly (billk . . cts.org) for pointing this out.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • version_0/ext/em.cpp

    r325 r332  
    5353        // objects before we start running. 
    5454        gCurrentLoopTime = time(NULL); 
     55 
     56        /* We initialize the network library here (only on Windows of course) 
     57         * and initialize "loop breakers." Our destructor also does some network-level 
     58         * cleanup. There's thus an implicit assumption that any given instance of EventMachine_t 
     59         * will only call ::Run once. Is that a good assumption? Should we move some of these 
     60         * inits and de-inits into ::Run? 
     61         */ 
     62        #ifdef OS_WIN32 
     63        WSADATA w; 
     64        WSAStartup (MAKEWORD (1, 1), &w); 
     65        #endif 
    5566 
    5667        _InitializeLoopBreaker(); 
     
    128139     * to that user. There is no meaningful implementation (and no error) 
    129140     * on Windows. On Unix, a failure to setuid the caller-supplied string 
    130      * causes a fatal abort, because presumably the program is calling us 
     141     * causes a fatal abort, because presumably the program is calling here 
    131142     * in order to fulfill a security requirement. If we fail silently, 
    132143     * the user may continue to run with too much privilege. 
     144     * 
     145     * TODO, we need to decide on and document a way of generating C++ level errors 
     146     * that can be wrapped in documented Ruby exceptions, so users can catch 
     147     * and handle them. And distinguish it from errors that we WON'T let the Ruby 
     148     * user catch (like security-violations and resource-overallocation). 
     149     * A setuid failure here would be in the latter category. 
    133150     */ 
    134151 
     
    220237{ 
    221238        #ifdef OS_WIN32 
    222         WSADATA w; 
    223         WSAStartup (MAKEWORD (1, 1), &w); 
    224239        HookControlC (true); 
    225240        #endif