return 0;
}
+int osrfAppRunChildInit(char* appname) {
+ osrfApplication* app = _osrfAppFindApplication(appname);
+ if(!app) return -1;
+
+ char* error;
+ int ret;
+ int (*childInit) (void);
+
+ *(void**) (&childInit) = dlsym(app->handle, "osrfAppChildInit");
+
+ if( (error = dlerror()) != NULL ) {
+ osrfLogInfo( OSRF_LOG_MARK, "No child init defined for app %s : %s", appname, error);
+ return 0;
+ }
+
+ if( (ret = (*childInit)()) ) {
+ osrfLogError(OSRF_LOG_MARK, "App %s child init failed", appname);
+ return -1;
+ }
+
+ osrfLogInfo(OSRF_LOG_MARK, "%s child init succeeded", appname);
+ return 0;
+}
+
int osrfAppRegisterMethod( char* appName, char* methodName,
char* symbolName, char* notes, int argc, int options ) {
#include "osrf_prefork.h"
#include <signal.h>
#include "osrf_app_session.h"
+#include "osrf_application.h"
/* true if we just deleted a child. This will allow us to make sure we're
not trying to use freed memory */
free(resc);
+ if( ! osrfAppRunChildInit(child->appname) ) {
+ osrfLogDebug(OSRF_LOG_MARK, "Prefork child_init succeeded\n");
+ } else {
+ osrfLogError(OSRF_LOG_MARK, "Prefork child_init failed\n");
+ }
+
set_proc_title( "OpenSRF Drone [%s]", child->appname );
}
return NULL;
}
+ osrfLogInfo(OSRF_LOG_MARK, "Prefork launching child with max_request=%d,"
+ "min_children=%d, max_children=%d", max_requests, min_children, max_children );
+
/* flesh out the struct */
prefork_simple* prefork = (prefork_simple*) safe_malloc(sizeof(prefork_simple));
prefork->max_requests = max_requests;
char buf[READ_BUFSIZE];
memset( buf, 0, READ_BUFSIZE );
- for( i = 0; i!= child->max_requests; i++ ) {
+ for( i = 0; i < child->max_requests; i++ ) {
n = -1;
clr_fl(child->read_data_fd, O_NONBLOCK );
}
if( n < 0 ) {
- osrfLogWarning( OSRF_LOG_MARK, "Child read returned error with errno %d", errno );
+ osrfLogWarning( OSRF_LOG_MARK, "Prefork child read returned error with errno %d", errno );
break;
}
buffer_free(gbuf);
- osrfLogDebug( OSRF_LOG_MARK, "Child exiting...[%d]", getpid() );
+ osrfLogDebug( OSRF_LOG_MARK, "Child with max-requests=%d, num-served=%d exiting...[%d]",
+ child->max_requests, i, getpid() );
exit(0);
}