From: John Hodge Date: Thu, 5 May 2011 06:04:58 +0000 (+0800) Subject: Fixed client error, added dead snack catch, fixing server io redirection X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=950aea956b32f7c63c6f31c60aaf57dbe9bc1a80;p=tpg%2Fopendispense2.git Fixed client error, added dead snack catch, fixing server io redirection --- diff --git a/src/client/main.c b/src/client/main.c index 0f7d525..83c66e2 100644 --- a/src/client/main.c +++ b/src/client/main.c @@ -816,10 +816,10 @@ int main(int argc, char *argv[]) if( j > 1 ) { printf("%i items dispensed\n", j); } + Dispense_ShowUser(sock, gsUserName); close(sock); - } - Dispense_ShowUser(sock, gsUserName); + } return ret; } diff --git a/src/server/dispense.c b/src/server/dispense.c index c3426fd..15962a3 100644 --- a/src/server/dispense.c +++ b/src/server/dispense.c @@ -120,6 +120,10 @@ int DispenseGive(int ActualUser, int SrcUser, int DestUser, int Ammount, const c char *actualUsername; char *srcName, *dstName; + // HACK: Naming a slot "dead" disables it (catch for snack) + if( strcmp(ReasonGiven, "dead") == 0 ) + return 1; + if( Ammount < 0 ) return 1; // Um... negative give? Not on my watch! ret = _Transfer( SrcUser, DestUser, Ammount, ReasonGiven ); diff --git a/src/server/server.c b/src/server/server.c index 483806a..9ee4ec7 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -164,9 +164,15 @@ void Server_Start(void) } // In child // - Sort out stdin/stdout + #if 0 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 ); + #else + freopen("/dev/null", "r", stdin); + freopen(gsServer_LogFile, "a", stdout); + freopen(gsServer_ErrorLog, "a", stderr); + #endif } // Start the helper thread