}
METHOD(stream_manager_t, start_service, bool,
- private_stream_manager_t *this, char *uri,
+ private_stream_manager_t *this, char *uri, int backlog,
stream_service_cb_t cb, void *data)
{
running_entry_t *running;
{
if (strpfx(uri, entry->prefix))
{
- service = entry->create(uri);
+ service = entry->create(uri, backlog);
if (service)
{
break;
* Start a new service under an URI, accept()ing client connections.
*
* @param uri URI of service to provide
+ * @param backlog size of the backlog queue, as passed to listen()
* @param cb callback function invoked for each client connection
* @param data user data to pass to callback
* @return TRUE if service started, FALSE on failure
*/
- bool (*start_service)(stream_manager_t *this, char *uri,
+ bool (*start_service)(stream_manager_t *this, char *uri, int backlog,
stream_service_cb_t cb, void *data);
/**
/**
* See header
*/
-stream_service_t *stream_service_create_unix(char *uri)
+stream_service_t *stream_service_create_unix(char *uri, int backlog)
{
struct sockaddr_un addr;
mode_t old;
DBG1(DBG_NET, "changing socket permissions for '%s' failed: %s",
uri, strerror(errno));
}
- if (listen(fd, 5) < 0)
+ if (listen(fd, backlog) < 0)
{
DBG1(DBG_NET, "listen on socket '%s' failed: %s", uri, strerror(errno));
unlink(addr.sun_path);
/**
* See header
*/
-stream_service_t *stream_service_create_tcp(char *uri)
+stream_service_t *stream_service_create_tcp(char *uri, int backlog)
{
union {
struct sockaddr_in in;
close(fd);
return NULL;
}
- if (listen(fd, 5) < 0)
+ if (listen(fd, backlog) < 0)
{
DBG1(DBG_NET, "listen on socket '%s' failed: %s", uri, strerror(errno));
close(fd);
#include <networking/streams/stream.h>
/**
- * Constructor function prototype for stream_servicet.
+ * Constructor function prototype for stream_service_t.
*
* @param uri URI to create a stream for
+ * @param backlog size of the backlog queue, as passed to listen()
* @return stream instance, NULL on error
*/
-typedef stream_service_t*(*stream_service_constructor_t)(char *uri);
+typedef stream_service_t*(*stream_service_constructor_t)(char *uri, int backlog);
/**
* Service callback routine for accepting client connections.
* Create a service instance for UNIX sockets.
*
* @param uri UNIX socket specific URI, must start with "unix://"
+ * @param backlog size of the backlog queue, as passed to listen()
* @return stream_service instance, NULL on failure
*/
-stream_service_t *stream_service_create_unix(char *uri);
+stream_service_t *stream_service_create_unix(char *uri, int backlog);
/**
* Create a service instance for TCP sockets.
*
* @param uri TCP socket specific URI, must start with "tcp://"
+ * @param backlog size of the backlog queue, as passed to listen()
* @return stream_service instance, NULL on failure
*/
-stream_service_t *stream_service_create_tcp(char *uri);
+stream_service_t *stream_service_create_tcp(char *uri, int backlog);
#endif /** STREAM_SERVICE_H_ @}*/