From: Martin Willi Date: Mon, 1 Jul 2013 12:57:28 +0000 (+0200) Subject: stream: support keeping the service alive outside of service callback X-Git-Tag: 5.1.0rc1~10^2~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6e8a2b2e01e91f75048fd4a33e04a0a7612bd12;p=thirdparty%2Fstrongswan.git stream: support keeping the service alive outside of service callback --- diff --git a/src/libstrongswan/networking/streams/stream_service.c b/src/libstrongswan/networking/streams/stream_service.c index 7eaca86be3..1b06e1eb14 100644 --- a/src/libstrongswan/networking/streams/stream_service.c +++ b/src/libstrongswan/networking/streams/stream_service.c @@ -124,8 +124,7 @@ static job_requeue_t accept_async(async_data_t *data) if (stream) { thread_cleanup_push((void*)stream->destroy, stream); - data->cb(data->data, stream); - thread_cleanup_pop(TRUE); + thread_cleanup_pop(!data->cb(data->data, stream)); } return JOB_REQUEUE_NONE; } diff --git a/src/libstrongswan/networking/streams/stream_service.h b/src/libstrongswan/networking/streams/stream_service.h index 27ef79148e..c8faba323c 100644 --- a/src/libstrongswan/networking/streams/stream_service.h +++ b/src/libstrongswan/networking/streams/stream_service.h @@ -39,12 +39,14 @@ typedef stream_service_t*(*stream_service_constructor_t)(char *uri, int backlog) /** * Service callback routine for accepting client connections. * - * The passed stream_service gets closed/destroyed by the callback caller. + * The passed stream gets closed/destroyed by the callback caller, unless + * TRUE is returned. * * @param data user data, as passed during registration * @param stream accept()ed client connection + * @return TRUE to keep stream alive, FALSE to destroy it */ -typedef void (*stream_service_cb_t)(void *data, stream_t *stream); +typedef bool (*stream_service_cb_t)(void *data, stream_t *stream); /** * A service accepting client connection streams.