GNU libmicrohttpd  0.9.72
action_suspend.c
Go to the documentation of this file.
1 /*
2  This file is part of libmicrohttpd
3  Copyright (C) 2007-2018 Daniel Pittman and Christian Grothoff
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19 
25 #include "internal.h"
26 
27 
36 static enum MHD_StatusCode
37 suspend_action (void *cls,
38  struct MHD_Request *request)
39 {
40  (void) cls;
41  struct MHD_Connection *connection = request->connection;
42  struct MHD_Daemon *daemon = connection->daemon;
43 
45  if (connection->resuming)
46  {
47  /* suspending again while we didn't even complete resuming yet */
48  connection->resuming = false;
50  return MHD_SC_OK;
51  }
52  if (daemon->threading_mode != MHD_TM_THREAD_PER_CONNECTION)
53  {
54  if (connection->connection_timeout ==
57  daemon->normal_timeout_tail,
58  connection);
59  else
61  daemon->manual_timeout_tail,
62  connection);
63  }
65  daemon->connections_tail,
66  connection);
67  mhd_assert (! connection->suspended);
70  connection);
71  connection->suspended = true;
72 #ifdef EPOLL_SUPPORT
73  if (MHD_ELS_EPOLL == daemon->event_loop_syscall)
74  {
75  if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EREADY_EDLL))
76  {
77  EDLL_remove (daemon->eready_head,
78  daemon->eready_tail,
79  connection);
80  connection->epoll_state &= ~MHD_EPOLL_STATE_IN_EREADY_EDLL;
81  }
82  if (0 != (connection->epoll_state & MHD_EPOLL_STATE_IN_EPOLL_SET))
83  {
84  if (0 != epoll_ctl (daemon->epoll_fd,
85  EPOLL_CTL_DEL,
86  connection->socket_fd,
87  NULL))
88  MHD_PANIC (_ ("Failed to remove FD from epoll set.\n"));
89  connection->epoll_state &= ~MHD_EPOLL_STATE_IN_EPOLL_SET;
90  }
91  connection->epoll_state |= MHD_EPOLL_STATE_SUSPENDED;
92  }
93 #endif
95  return MHD_SC_OK;
96 }
97 
98 
126 const struct MHD_Action *
128 {
129  static const struct MHD_Action suspend = {
131  .action_cls = NULL
132  };
133 
134  return &suspend;
135 }
136 
137 
138 /* end of action_suspend.c */
const struct MHD_Action * MHD_action_suspend(void)
static enum MHD_StatusCode suspend_action(void *cls, struct MHD_Request *request)
@ MHD_EPOLL_STATE_SUSPENDED
Definition: internal.h:621
@ MHD_EPOLL_STATE_IN_EREADY_EDLL
Definition: internal.h:611
@ MHD_EPOLL_STATE_IN_EPOLL_SET
Definition: internal.h:616
#define DLL_insert(head, tail, element)
Definition: internal.h:1743
#define MHD_PANIC(msg)
Definition: internal.h:69
#define EDLL_remove(head, tail, element)
Definition: internal.h:1847
#define XDLL_remove(head, tail, element)
Definition: internal.h:1806
#define DLL_remove(head, tail, element)
Definition: internal.h:1763
#define mhd_assert(CHK)
Definition: mhd_assert.h:39
#define MHD_mutex_unlock_chk_(pmutex)
Definition: mhd_locks.h:180
#define MHD_mutex_lock_chk_(pmutex)
Definition: mhd_locks.h:154
#define NULL
Definition: reason_phrase.c:30
#define _(String)
Definition: mhd_options.h:42
internal shared structures
ActionCallback action
Definition: internal.h:1554
MHD_socket socket_fd
Definition: internal.h:752
bool suspended
Definition: internal.h:764
struct MHD_Request request
Definition: internal.h:717
time_t connection_timeout
Definition: internal.h:745
struct MHD_Daemon * daemon
Definition: internal.h:675
MHD_mutex_ cleanup_connection_mutex
Definition: internal.h:1265
struct MHD_Connection * connections_head
Definition: internal.h:1155
enum MHD_EventLoopSyscall event_loop_syscall
Definition: internal.h:1436
struct MHD_Connection * manual_timeout_tail
Definition: internal.h:1150
time_t connection_default_timeout
Definition: internal.h:1371
struct MHD_Connection * manual_timeout_head
Definition: internal.h:1143
struct MHD_Connection * suspended_connections_tail
Definition: internal.h:1172
struct MHD_Connection * normal_timeout_head
Definition: internal.h:1128
struct MHD_Connection * normal_timeout_tail
Definition: internal.h:1135
enum MHD_ThreadingMode threading_mode
Definition: internal.h:1417
struct MHD_Connection * suspended_connections_head
Definition: internal.h:1166
struct MHD_Connection * connections_tail
Definition: internal.h:1160
struct MHD_Connection * connection
Definition: internal.h:377