[netperf-dev] netperf4 commit notice r196 - in trunk: doc/examples
src
raj at netperf.org
raj at netperf.org
Thu Aug 24 14:59:55 PDT 2006
Author: raj
Date: 2006-08-24 14:59:54 -0700 (Thu, 24 Aug 2006)
New Revision: 196
Added:
trunk/doc/examples/netperf4.xinetd
Modified:
trunk/src/netserver.c
Log:
make netserver work as child of inetd again - at least if you add --nodaemonize --nospawn
Added: trunk/doc/examples/netperf4.xinetd
===================================================================
--- trunk/doc/examples/netperf4.xinetd 2006-08-24 20:21:18 UTC (rev 195)
+++ trunk/doc/examples/netperf4.xinetd 2006-08-24 21:59:54 UTC (rev 196)
@@ -0,0 +1,15 @@
+# default: off
+# description: An netperf4 server.
+# This is the tcp version.
+service netperf4
+{
+ disable = no
+ socket_type = stream
+ protocol = tcp
+ user = root
+ wait = no
+ server = /opt/netperf4/bin/netserver
+ server_args = --nodaemonize --nospawn
+}
+
+# There is no udp version.
Modified: trunk/src/netserver.c
===================================================================
--- trunk/src/netserver.c 2006-08-24 20:21:18 UTC (rev 195)
+++ trunk/src/netserver.c 2006-08-24 21:59:54 UTC (rev 196)
@@ -194,7 +194,9 @@
SOCKET toclose;
toclose = atoi(option_value);
- g_fprintf(where,"was asked to close socket %d\n",toclose);
+ if (debug) {
+ g_fprintf(where,"was asked to close socket %d\n",toclose);
+ }
#ifdef G_OS_WIN32
closesocket(toclose);
#else
@@ -695,7 +697,9 @@
global_state_t *global_state;
guint watch_id;
- g_fprintf(where,"accepting a new connection\n");
+ if (debug) {
+ g_fprintf(where,"accepting a new connection\n");
+ }
global_state = data;
@@ -974,7 +978,7 @@
int i;
struct sockaddr name;
netperf_socklen_t namelen = sizeof(name);
- SOCKET sock, listen_sock;
+ SOCKET listen_sock;
guint watch_id;
GOptionContext *option_context;
@@ -1025,8 +1029,11 @@
}
/* if we daemonize, we will not be returning, and we will be
- starting a whole new instance of this binary, because that is what
- g_spawn_async_with_pipes() does. */
+ starting a whole new instance of this binary, because that is
+ what g_spawn_async_with_pipes() does. i'm rather confident that
+ this needs to be moved after the check for inetd - to make things
+ more robust when folks forget to add --nodaemonize to the
+ argument list in the inetd config file. raj 2006-08-24 */
if (want_daemonize) {
daemonize(orig_argc,orig_argv);
}
@@ -1039,12 +1046,11 @@
if (getsockname(0, &name, &namelen) == 0) {
/* we are a child of inetd or the like */
need_setup = FALSE;
- sock = 0;
+ control_socket = 0;
}
else if (getsockname(control_socket, &name, &namelen) == 0) {
/* we were spawned by a parent netserver */
need_setup = FALSE;
- sock = control_socket;
}
else {
need_setup = TRUE;
@@ -1157,6 +1163,11 @@
/* we used to call handle_netperf_requests(sock); here, now we use
the loop, luke... */
+ if (debug) {
+ fprintf(where,"control_socket is %d\n",control_socket);
+ fflush(where);
+ }
+
#ifdef G_OS_WIN32
control_channel = g_io_channel_win32_new_socket(control_socket);
#else
More information about the netperf-dev
mailing list