Changeset 14574


Ignore:
Timestamp:
Oct 11, 2015, 4:35:51 PM (6 years ago)
Author:
mikedld
Message:

Initialise networking in daemon before making libevent calls

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/daemon.c

    r14532 r14574  
    495495    sd_notifyf (0, "MAINPID=%d\n", (int)getpid());
    496496
     497    /* should go before libevent calls */
     498    tr_net_init ();
     499
    497500    /* setup event state */
    498     ev_base = event_base_new();
     501    ev_base = event_base_new ();
    499502    if (ev_base == NULL)
    500503    {
    501504        char buf[256];
    502         tr_snprintf(buf, sizeof(buf), "Failed to init daemon event state: %s", tr_strerror(errno));
     505        tr_snprintf (buf, sizeof (buf), "Failed to init daemon event state: %s", tr_strerror (errno));
    503506        printMessage (logfile, TR_LOG_ERROR, MY_NAME, buf, __FILE__, __LINE__);
    504507        return 1;
  • trunk/libtransmission/net.c

    r14549 r14574  
    5656const tr_address tr_inaddr_any = { TR_AF_INET, { { { { INADDR_ANY, 0x00, 0x00, 0x00 } } } } };
    5757
    58 void
    59 tr_netInit (void)
    60 {
    61     static bool initialized = false;
    62 
    63     if (!initialized)
    64     {
    65 #ifdef _WIN32
    66         WSADATA wsaData;
    67         WSAStartup (MAKEWORD (2, 2), &wsaData);
    68 #endif
    69         initialized = true;
    70     }
    71 }
    72 
    7358char *
    7459tr_net_strerror (char * buf, size_t buflen, int err)
  • trunk/libtransmission/net.h

    r14531 r14574  
    164164void tr_netCloseSocket (tr_socket_t fd);
    165165
    166 void tr_netInit (void);
    167 
    168166bool tr_net_hasIPv6 (tr_port);
    169167
  • trunk/libtransmission/session.c

    r14526 r14574  
    611611
    612612  /* start the libtransmission thread */
    613   tr_netInit (); /* must go before tr_eventInit */
     613  tr_net_init (); /* must go before tr_eventInit */
    614614  tr_eventInit (session);
    615615  assert (session->events != NULL);
  • trunk/libtransmission/utils.c

    r14573 r14574  
    3030
    3131#ifdef _WIN32
     32 #include <ws2tcpip.h> /* WSAStartup () */
    3233 #include <windows.h> /* Sleep (), GetSystemTimeAsFileTime (), GetEnvironmentVariable () */
    3334 #include <shellapi.h> /* CommandLineToArgv () */
     
    18431844#endif
    18441845}
     1846
     1847/***
     1848****
     1849***/
     1850
     1851void
     1852tr_net_init (void)
     1853{
     1854    static bool initialized = false;
     1855
     1856    if (!initialized)
     1857    {
     1858#ifdef _WIN32
     1859        WSADATA wsaData;
     1860        WSAStartup (MAKEWORD (2, 2), &wsaData);
     1861#endif
     1862        initialized = true;
     1863    }
     1864}
  • trunk/libtransmission/utils.h

    r14504 r14574  
    505505***/
    506506
     507void tr_net_init (void);
     508
     509/***
     510****
     511***/
     512
    507513#ifdef __cplusplus
    508514}
Note: See TracChangeset for help on using the changeset viewer.