Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

WIP: new conn 2

  • Loading branch information...
commit 216073a604d3e0a84ae6e1e9b2f5136bc2f3f042 1 parent 390c8b3
@alobbs alobbs authored
Showing with 148 additions and 0 deletions.
  1. +94 −0 cherokee/connection.c
  2. +54 −0 cherokee/connection.h
View
94 cherokee/connection.c
@@ -0,0 +1,94 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/* Cherokee
+ *
+ * Authors:
+ * Alvaro Lopez Ortega <alvaro@alobbs.com>
+ *
+ * Copyright (C) 2001-2011 Alvaro Lopez Ortega
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#include "common-internal.h"
+#include "connection.h"
+
+
+ret_t
+cherokee_connection_init (cherokee_connection_t *conn)
+{
+ conn->keepalive = 0;
+
+ cherokee_socket_init (&conn->socket);
+ cherokee_connection_poll_init (&conn->polling_aim);
+
+ INIT_LIST_HEAD (&conn->requests);
+ return ret_ok;
+}
+
+
+static void
+reuse_requests (cherokee_connection_t *conn)
+{
+ cherokee_thread_t *thd = CONN_THREAD(conn);
+ cherokee_list_t *i, *tmp;
+
+ list_for_each_safe (i, tmp, &conn->requests) {
+ if (thd != NULL) {
+ cherokee_thread_recycle_request (thd, REQ(i));
+ } else {
+ cherokee_request_free (REQ(i));
+ }
+ }
+}
+
+
+ret_t
+cherokee_connection_mrproper (cherokee_connection_t *conn)
+{
+ /* Polling aim */
+ if (conn->polling_aim.fd != -1) {
+ cherokee_fd_close (conn->polling_aim.fd);
+ }
+
+ cherokee_connection_poll_mrproper (&conn->polling_aim);
+
+ /* Connection socket */
+ cherokee_socket_mrproper (&conn->socket);
+
+ /* Free requests */
+ reuse_requests (conn);
+
+ return ret_ok;
+}
+
+
+ret_t
+cherokee_connection_clean (cherokee_connection_t *conn)
+{
+ cherokee_list_t *i, *tmp;
+
+ /* Polling aim */
+ if (conn->polling_aim.fd != -1) {
+ cherokee_fd_close (conn->polling_aim.fd);
+ }
+
+ cherokee_connection_poll_clean (&conn->polling_aim);
+
+ /* Free requests */
+ reuse_requests (conn);
+
+ return ret_ok;
+}
View
54 cherokee/connection.h
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/* Cherokee
+ *
+ * Authors:
+ * Alvaro Lopez Ortega <alvaro@alobbs.com>
+ *
+ * Copyright (C) 2001-2011 Alvaro Lopez Ortega
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ */
+
+#ifndef CHEROKEE_REQUEST_H
+#define CHEROKEE_REQUEST_H
+
+#include "common.h"
+#include "buffer.h"
+#include "socket.h"
+#include "list.h"
+#include "connection-poll.h"
+
+CHEROKEE_BEGIN_DECLS
+
+typedef struct {
+ cherokee_socket_t socket;
+ uint32_t keepalive;
+ cherokee_connection_pool_t polling_aim;
+ cherokee_list_t requests;
+} cherokee_connection_t;
+
+#define CONN(c) ((cherokee_connection_t *)(c))
+
+
+/* Public methods
+ */
+ret_t cherokee_connection_init (cherokee_connection_t *conn);
+ret_t cherokee_connection_mrproper (cherokee_connection_t *conn);
+
+
+CHEROKEE_END_DECLS
+
+#endif /* CHEROKEE_REQUEST_H */
Please sign in to comment.
Something went wrong with that request. Please try again.