From: John Hodge Date: Wed, 4 May 2011 06:49:49 +0000 (+0800) Subject: Extra help info, fixed logging for dispense failures, possible fix for logging errors X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=8a516dd60ab15cf514481c74dd087a294915565d;p=tpg%2Fopendispense2.git Extra help info, fixed logging for dispense failures, possible fix for logging errors --- diff --git a/src/client/main.c b/src/client/main.c index b16c495..0f7d525 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -161,6 +161,8 @@ void ShowUsage(void) printf( " dispense refund []\n" " Refund an item to a user (with optional price override)\n" + " Item IDs can be seen in the cokelog (in the brackets after the item name)\n" + " e.g. coke:6 for a coke, snack:33 for slot 33 of the snack machine\n" ); if( giTextArgc == 0 || strcmp(gsTextArgs[0], "slot") == 0 ) printf( diff --git a/src/server/dispense.c b/src/server/dispense.c index 8375ab6..c3426fd 100644 --- a/src/server/dispense.c +++ b/src/server/dispense.c @@ -50,7 +50,7 @@ int DispenseItem(int ActualUser, int User, tItem *Item) ret = handler->DoDispense( User, Item->ID ); if(ret) { Log_Error("Dispense failed (%s dispensing %s:%i '%s')", - username, Item->Name, Item->Handler->Name, Item->ID); + username, Item->Handler->Name, Item->ID, Item->Name); free( username ); return -1; // 1: Unknown Error again } diff --git a/src/server/server.c b/src/server/server.c index 99ea10e..483806a 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -152,7 +152,6 @@ void Server_Start(void) // Fork into background if( gbServer_RunInBackground ) { - int newin, newout, newerr; int pid = fork(); if( pid == -1 ) { fprintf(stderr, "ERROR: Unable to fork\n"); @@ -165,12 +164,9 @@ void Server_Start(void) } // In child // - Sort out stdin/stdout - newin = open("/dev/null", O_RDONLY); - newout = open(gsServer_LogFile, O_CREAT|O_APPEND, 0644); - newerr = open(gsServer_ErrorLog, O_CREAT|O_APPEND, 0644); - dup2(newin, 0); - dup2(newout, 1); - dup2(newerr, 2); + dup2( open("/dev/null", O_RDONLY, 0644), STDIN_FILENO ); + dup2( open(gsServer_LogFile, O_CREAT|O_APPEND, 0644), STDOUT_FILENO ); + dup2( open(gsServer_ErrorLog, O_CREAT|O_APPEND, 0644), STDERR_FILENO ); } // Start the helper thread