Author: rfm Date: Thu May 5 16:35:52 2016 New Revision: 39723 URL: http://svn.gna.org/viewcvs/gnustep?rev=39723&view=rev Log: stop responses being completed more than once
Modified: libs/webserver/trunk/ChangeLog libs/webserver/trunk/Internal.h libs/webserver/trunk/WebServer.m libs/webserver/trunk/WebServerConnection.m Modified: libs/webserver/trunk/ChangeLog URL: http://svn.gna.org/viewcvs/gnustep/libs/webserver/trunk/ChangeLog?rev=39723&r1=39722&r2=39723&view=diff ============================================================================== --- libs/webserver/trunk/ChangeLog (original) +++ libs/webserver/trunk/ChangeLog Thu May 5 16:35:52 2016 @@ -1,3 +1,10 @@ +2016-05-05 Richard Frith-Macdonald <r...@gnu.org> + + * WebServerConnection.m: + * WebServer.m: + * Internal.h: + Check to prevent a response being completed more than once. + 2016-01-20 Niels Grewe <niels.g...@halbordnung.de> * WebServerHeader.m: Fix the x-count-* headers. The WSHType Modified: libs/webserver/trunk/Internal.h URL: http://svn.gna.org/viewcvs/gnustep/libs/webserver/trunk/Internal.h?rev=39723&r1=39722&r2=39723&view=diff ============================================================================== --- libs/webserver/trunk/Internal.h (original) +++ libs/webserver/trunk/Internal.h Thu May 5 16:35:52 2016 @@ -117,10 +117,13 @@ WebServerConnection *webServerConnection; BOOL prepared; BOOL foldHeaders; -} + BOOL completing; +} +- (BOOL) completing; - (BOOL) foldHeaders; - (BOOL) prepared; - (void) setFoldHeaders: (BOOL)aFlag; +- (void) setCompleting; - (void) setPrepared; - (void) setWebServerConnection: (WebServerConnection*)c; - (WebServerConnection*) webServerConnection; Modified: libs/webserver/trunk/WebServer.m URL: http://svn.gna.org/viewcvs/gnustep/libs/webserver/trunk/WebServer.m?rev=39723&r1=39722&r2=39723&view=diff ============================================================================== --- libs/webserver/trunk/WebServer.m (original) +++ libs/webserver/trunk/WebServer.m Thu May 5 16:35:52 2016 @@ -895,6 +895,12 @@ format: @"[%@-%@] argument is not a valid response object", NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; } + if (YES == [response completing]) + { + [NSException raise: NSInvalidArgumentException + format: @"[%@-%@] argument is already completing", + NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; + } if (YES == _doPostProcess) { [_pool scheduleSelector: @selector(_process4:) @@ -904,12 +910,27 @@ else { WebServerConnection *connection; + BOOL wasCompleting; [_lock lock]; - _processingCount--; - connection = [[response webServerConnection] retain]; + wasCompleting = [response completing]; + if (NO == wasCompleting) + { + [response setCompleting]; + _processingCount--; + connection = [[response webServerConnection] retain]; + } + [response setWebServerConnection: nil]; [_lock unlock]; - if (nil == connection) + if (YES == wasCompleting) + { + if (YES == _conf->verbose) + { + [self _log: @"Called -completedWithResponse: for a response" + @" which is already complete: %@", response]; + } + } + else if (nil == connection) { if (YES == _conf->verbose) { Modified: libs/webserver/trunk/WebServerConnection.m URL: http://svn.gna.org/viewcvs/gnustep/libs/webserver/trunk/WebServerConnection.m?rev=39723&r1=39722&r2=39723&view=diff ============================================================================== --- libs/webserver/trunk/WebServerConnection.m (original) +++ libs/webserver/trunk/WebServerConnection.m Thu May 5 16:35:52 2016 @@ -251,6 +251,11 @@ } } +- (BOOL) completing +{ + return completing; +} + - (id) copy { return [self retain]; @@ -302,6 +307,11 @@ - (BOOL) prepared { return prepared; +} + +- (void) setCompleting +{ + completing = YES; } - (void) setFoldHeaders: (BOOL)aFlag _______________________________________________ Gnustep-cvs mailing list Gnustep-cvs@gna.org https://mail.gna.org/listinfo/gnustep-cvs