From dc6a01fe8ac89530dce4e8c13d15212ed73a9ebf Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 18 Sep 2005 04:59:22 +0000 Subject: [PATCH] Fixed a bug in AppServer --- src/appclient.c | 25 ++++++++++--------------- src/appinterface.c | 6 +++++- src/appserver.c | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/appclient.c b/src/appclient.c index ed77dd0..dcd7d9d 100644 --- a/src/appclient.c +++ b/src/appclient.c @@ -21,8 +21,8 @@ /* types */ struct _AppClient { - Event * event; AppInterface * interface; + Event * event; int fd; #define ASC_BUFSIZE 65536 /* FIXME */ char buf_read[ASC_BUFSIZE]; @@ -108,6 +108,11 @@ AppClient * appclient_new_event(char * app, Event * event) #endif if((appclient = malloc(sizeof(AppClient))) == NULL) return NULL; + if((appclient->interface = appinterface_new("Session")) == NULL) + { + free(appclient); + return NULL; + } appclient->event = event; appclient->fd = -1; appclient->buf_read_cnt = 0; @@ -132,15 +137,14 @@ static int _new_connect(AppClient * appclient, char * app) sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK); if(connect(appclient->fd, &sa, sizeof(sa)) != 0) return 1; -/* event_register_timeout(appclient->event, tv, - (EventTimeoutFunc)_appclient_timeout, appclient); - event_register_io_write(appclient->event, appclient->fd, - (EventIOFunc)_appclient_write, appclient); */ - if((port = appclient_call(appclient, "info", app)) == -1) + if((port = appclient_call(appclient, "port", app)) == -1) return 1; if(port == 0) return 0; close(appclient->fd); + appinterface_delete(appclient->interface); + if((appclient->interface = appinterface_new(app)) == NULL) + return 1; if((appclient->fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) return 1; sa.sin_port = htons(port); @@ -166,15 +170,6 @@ int appclient_call(AppClient * ac, char * function, ...) void ** p; struct timeval tv = { 0, 10 }; -/* for(i = 0; i < appclient->ascc_cnt; i++) - { - if(string_compare(appclient->ascc[i].name, function) != 0) - continue; - ascc = &appclient->ascc[i]; - break; - } - if(ascc == NULL) - return -1; */ va_start(arg, function); for(i = 0; i < 0 /* FIXME XXX */; i++) { diff --git a/src/appinterface.c b/src/appinterface.c index 47d9132..4d8e004 100644 --- a/src/appinterface.c +++ b/src/appinterface.c @@ -91,6 +91,10 @@ static int _new_append(AppInterface * ai, AppInterfaceCallType type, int i; int j; +#ifdef DEBUG + fprintf(stderr, "%s%s%s%d%s", "interface supports ", function, "(", + args_cnt, ")\n"); +#endif for(i = 0; i < ai->calls_cnt; i++) if(string_compare(ai->calls[i].name, function) == 0) return 1; @@ -111,7 +115,7 @@ static int _new_append(AppInterface * ai, AppInterfaceCallType type, for(j = 0; j < args_cnt; j++) ai->calls[i].args[j] = va_arg(args, AppInterfaceCallType); va_end(args); - return i == args_cnt ? 0 : 1; + return 0; } static int _new_session(AppInterface * appinterface) diff --git a/src/appserver.c b/src/appserver.c index 1e7eea3..575d18b 100644 --- a/src/appserver.c +++ b/src/appserver.c @@ -228,7 +228,7 @@ AppServer * appserver_new_event(char const * app, int options, Event * event) appserver->clients = NULL; if((appserver->clients = AppServerClientarray_new()) == NULL || (appserver->interface = appinterface_new(app)) - != NULL + == NULL || _new_server(appserver, options) != 0) { if(appserver->clients != NULL)