1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-10 22:22:58 +00:00

(libT) make sure to init the rpc server with the correct event base.

This commit is contained in:
Charles Kerr 2008-09-29 04:26:52 +00:00
parent 713b99d64b
commit 86b6e00321
3 changed files with 16 additions and 6 deletions

View file

@ -28,6 +28,7 @@
#include "platform.h" #include "platform.h"
#include "rpcimpl.h" #include "rpcimpl.h"
#include "rpc-server.h" #include "rpc-server.h"
#include "trevent.h"
#include "utils.h" #include "utils.h"
#include "web.h" #include "web.h"
@ -327,7 +328,7 @@ handle_request( struct evhttp_request * req,
void * arg ) void * arg )
{ {
struct tr_rpc_server * server = arg; struct tr_rpc_server * server = arg;
tr_ndbg( MY_NAME, _( "Got request: \"%s\"" ), req->uri ); fprintf( stderr, "%s:%d Got request: \"%s\"\n", __FILE__, __LINE__, req->uri );
if( req && req->evcon ) if( req && req->evcon )
{ {
@ -393,19 +394,21 @@ handle_request( struct evhttp_request * req,
tr_free( user ); tr_free( user );
} }
fprintf( stderr, "%s:%d\n", __FILE__, __LINE__ );
} }
static void static void
startServer( tr_rpc_server * server ) startServer( tr_rpc_server * server )
{ {
dbgmsg( "in startServer; current context is %p", server->httpd ); fprintf( stderr, "%s:%d in startServer; current context is %p\n", __FILE__, __LINE__, server->httpd );
if( !server->httpd ) if( !server->httpd )
{ {
if( ( server->httpd = evhttp_start( "0.0.0.0", server->port ) ) ) int i;
evhttp_set_gencb( server->httpd, handle_request, server ); server->httpd = evhttp_new( tr_eventGetBase( server->session ) );
else fprintf( stderr, "%s:%d in startServer; new context is %p\n", __FILE__, __LINE__, server->httpd );
tr_nerr( MY_NAME, _( "Failed to start RPC server" ) ); i = evhttp_bind_socket( server->httpd, "0.0.0.0", server->port );
fprintf( stderr, "evhttp_bind_socket returned %d\n", i );
} }
} }

View file

@ -302,3 +302,8 @@ tr_runInEventThread( struct tr_handle * handle,
} }
} }
struct event_base *
tr_eventGetBase( tr_session * session )
{
return session->events->base;
}

View file

@ -22,6 +22,8 @@ void tr_eventInit( struct tr_handle * tr_handle );
void tr_eventClose( struct tr_handle * tr_handle ); void tr_eventClose( struct tr_handle * tr_handle );
struct event_base * tr_eventGetBase( struct tr_handle * tr_handle );
typedef struct tr_timer tr_timer; typedef struct tr_timer tr_timer;