Fixed client error, added dead snack catch, fixing server io redirection
authorJohn Hodge <[email protected]>
Thu, 5 May 2011 06:04:58 +0000 (14:04 +0800)
committerJohn Hodge <[email protected]>
Thu, 5 May 2011 06:04:58 +0000 (14:04 +0800)
src/client/main.c
src/server/dispense.c
src/server/server.c

index 0f7d525..83c66e2 100644 (file)
@@ -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;
 }
index c3426fd..15962a3 100644 (file)
@@ -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 );
index 483806a..9ee4ec7 100644 (file)
@@ -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

UCC git Repository :: git.ucc.asn.au