Mercurial > noffle
comparison src/server.c @ 144:8b9366fc1361 noffle
[svn] Added timeout to Prt_getLn to avoid Noffle hanging if the
connection breaks down during a fetch.
author | enz |
---|---|
date | Sat, 23 Sep 2000 11:40:35 +0100 |
parents | 3c71e28c8eef |
children | bfeea2bc09b6 |
comparison
equal
deleted
inserted
replaced
143:7400a8e9d5ba | 144:8b9366fc1361 |
---|---|
1 /* | 1 /* |
2 server.c | 2 server.c |
3 | 3 |
4 $Id: server.c 183 2000-07-25 12:14:54Z bears $ | 4 $Id: server.c 217 2000-09-23 10:40:35Z enz $ |
5 */ | 5 */ |
6 | 6 |
7 #if HAVE_CONFIG_H | 7 #if HAVE_CONFIG_H |
8 #include <config.h> | 8 #include <config.h> |
9 #endif | 9 #endif |
244 ASSERT( timeoutSeconds >= 0 ); | 244 ASSERT( timeoutSeconds >= 0 ); |
245 | 245 |
246 /* Special case - no timeout. */ | 246 /* Special case - no timeout. */ |
247 if ( timeoutSeconds == 0 ) | 247 if ( timeoutSeconds == 0 ) |
248 { | 248 { |
249 r = Prt_getLn( line, stdin ); | 249 r = Prt_getLn( line, stdin, -1 ); |
250 return ( r ) ? 1 : -1; | 250 return ( r ) ? 1 : -1; |
251 } | 251 } |
252 | 252 |
253 server.readAlarmFlag = FALSE; | 253 server.readAlarmFlag = FALSE; |
254 oldHandler = installSignalHandler( SIGALRM, readAlarm ); | 254 oldHandler = installSignalHandler( SIGALRM, readAlarm ); |
257 Log_err( "client.c:connectWithTimeout: signal failed." ); | 257 Log_err( "client.c:connectWithTimeout: signal failed." ); |
258 return -1; | 258 return -1; |
259 } | 259 } |
260 if ( alarm( ( unsigned int ) timeoutSeconds ) != 0 ) | 260 if ( alarm( ( unsigned int ) timeoutSeconds ) != 0 ) |
261 Log_err( "server.c:waitCmdLn: Alarm was already set." ); | 261 Log_err( "server.c:waitCmdLn: Alarm was already set." ); |
262 r = Prt_getLn( line, stdin ); | 262 r = Prt_getLn( line, stdin, -1 ); |
263 alarm( 0 ); | 263 alarm( 0 ); |
264 installSignalHandler( SIGALRM, oldHandler ); | 264 installSignalHandler( SIGALRM, oldHandler ); |
265 if ( server.readAlarmFlag ) | 265 if ( server.readAlarmFlag ) |
266 return 0; | 266 return 0; |
267 else if ( r ) | 267 else if ( r ) |
270 } | 270 } |
271 | 271 |
272 static Bool | 272 static Bool |
273 getTxtLn( Str line, Bool *err ) | 273 getTxtLn( Str line, Bool *err ) |
274 { | 274 { |
275 return Prt_getTxtLn( line, err, stdin ); | 275 return Prt_getTxtLn( line, err, stdin, -1 ); |
276 } | 276 } |
277 | 277 |
278 static Bool | 278 static Bool |
279 notImplemented( char *arg, const Cmd *cmd ) | 279 notImplemented( char *arg, const Cmd *cmd ) |
280 { | 280 { |