summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index f83dde3..2295752 100644
--- a/thread.c
+++ b/thread.c
@@ -444,6 +444,13 @@ void dispatch_conn_new(int sfd, enum conn_states init_state, int event_flags,
int read_buffer_size, enum network_transport transport) {
CQ_ITEM *item = cqi_new();
char buf[1];
+ if (item == NULL) {
+ close(sfd);
+ /* given that malloc failed this may also fail, but let's try */
+ fprintf(stderr, "Failed to allocate memory for connection object\n");
+ return ;
+ }
+
int tid = (last_thread + 1) % settings.num_threads;
LIBEVENT_THREAD *thread = threads + tid;