[Initng-svn] r1970 - in initng: initfiles/debug plugins/ngc2
svn at initng.thinktux.net
svn at initng.thinktux.net
Mon Nov 7 11:07:33 CET 2005
Author: jimmy
Date: Mon Nov 7 11:07:32 2005
New Revision: 1970
Modified:
initng/initfiles/debug/fstat-test.ii
initng/plugins/ngc2/ngc2.c
Log:
Make ngc only wait 10 seconds for a service to stop/start, also dint print the header more then once.
Modified: initng/initfiles/debug/fstat-test.ii
==============================================================================
--- initng/initfiles/debug/fstat-test.ii (original)
+++ initng/initfiles/debug/fstat-test.ii Mon Nov 7 11:07:32 2005
@@ -1,3 +1,3 @@
service debug/fstat-test {
- files_to_exist = /test
+ require_file = /test
}
Modified: initng/plugins/ngc2/ngc2.c
==============================================================================
--- initng/plugins/ngc2/ngc2.c (original)
+++ initng/plugins/ngc2/ngc2.c Mon Nov 7 11:07:32 2005
@@ -48,6 +48,7 @@
#define FALSE 0
int debug = 0;
+int header_printed=FALSE;
/* Global comunication socket */
static int sock = -1;
@@ -177,19 +178,22 @@
/* read header data */
read(sock, result, sizeof(result_desc));
-
- printf("Got an response from initng, version: %s\n", result->version);
-
- if (strcmp(result->version, VERSION) != 0)
+ if(header_printed==FALSE)
{
- printf("Version of initng and version of ngc differs!\n");
- printf
+ printf("Got an response from initng, version: %s\n", result->version);
+
+ if (strcmp(result->version, VERSION) != 0)
+ {
+ printf("Version of initng and version of ngc differs!\n");
+ printf
("this might be a bad thing, that Can in worst case cause problems!\n");
- }
+ }
- /*printf("got an read: command %c, status %i, type %i\n", result->c,
+ /*printf("got an read: command %c, status %i, type %i\n", result->c,
result->s, result->t); */
-
+ header_printed=TRUE;
+ }
+
if (result->s == FALSE)
{
printf("result of %c is false = %i!\n", result->c, result->s);
@@ -223,10 +227,11 @@
{
active_row row;
result_desc *result = NULL;
+ int counter = 0;
printf("Starting service: \n");
- while (TRUE)
+ while (counter<10)
{
read(sock, &row, sizeof(active_row));
close_socket();
@@ -251,6 +256,7 @@
close_socket();
return (FALSE);
}
+ counter++;
}
close_socket();
@@ -261,6 +267,13 @@
return (TRUE);
}
+ if(counter==10)
+ {
+ printf("Timeout on start service, might be started soon anyway.\n");
+ return(FALSE);
+ }
+
+
printf("\tFailed to start service, %s (%s)\n", row.n,
active_db_get_status_string(row.s));
return (FALSE);
@@ -271,6 +284,7 @@
{
active_row row;
result_desc *result = NULL;
+ int counter=0;
printf("Stopping service: \n");
@@ -280,7 +294,7 @@
goto cant;
- while (TRUE)
+ while (counter<10)
{
/* sleep awhile */
sleep(1);
@@ -305,7 +319,7 @@
if (strlen(row.n) < 2)
break;
-
+ counter++;
}
close_socket();
@@ -314,6 +328,12 @@
printf("\tService stopped sucessfully!\n");
return (TRUE);
}
+
+ if(counter==10)
+ {
+ printf("Timeout on stop service, might be stopped soon anyway.\n");
+ return(FALSE);
+ }
cant:
printf("\tFailed to stop service, %s (%s)\n", row.n,
@@ -385,7 +405,7 @@
{
int cc = 1;
result_desc *result = NULL;
-
+ header_printed=FALSE;
Argv = argv[0];
/* print banner */
More information about the Initng-svn
mailing list