GNU libmicrohttpd  0.9.72
connection_close.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 */
24 #include "internal.h"
25 #include "connection_close.h"
26 
27 
35 void
37 {
38  const struct MHD_Daemon *daemon = connection->daemon;
39 
40  connection->request.state = MHD_REQUEST_CLOSED;
42  if (! daemon->enable_turbo)
43  {
44 #ifdef HTTPS_SUPPORT
45  struct MHD_TLS_Plugin *tls;
46 
47  /* For TLS connection use shutdown of TLS layer
48  * and do not shutdown TCP socket. This give more
49  * chances to send TLS closure data to remote side.
50  * Closure of TLS layer will be interpreted by
51  * remote side as end of transmission. */if (NULL != (tls = daemon->tls_api))
52  {
53  if (MHD_YES !=
54  tls->shutdown_connection (tls->cls,
55  connection->tls_cs))
56  {
57  (void) shutdown (connection->socket_fd,
58  SHUT_WR);
59  /* FIXME: log errors */
60  }
61  }
62  else /* Combined with next 'shutdown()'. */
63 #endif /* HTTPS_SUPPORT */
64  {
65  (void) shutdown (connection->socket_fd,
66  SHUT_WR); /* FIXME: log errors */
67  }
68  }
69 }
70 
71 
82 void
85 {
86  struct MHD_Daemon *daemon = connection->daemon;
87  struct MHD_Response *resp = connection->request.response;
88 
89  (void) rtc; // FIXME
90  MHD_connection_mark_closed_ (connection);
91  if (NULL != resp)
92  {
93  connection->request.response = NULL;
95  }
96  if (NULL != daemon->notify_connection_cb)
98  connection,
100 }
101 
102 
103 /* end of connection_close.c */
void MHD_connection_mark_closed_(struct MHD_Connection *connection)
void MHD_connection_close_(struct MHD_Connection *connection, enum MHD_RequestTerminationCode rtc)
functions to close connection
MHD_RequestTerminationCode
Definition: microhttpd.h:1832
@ MHD_CONNECTION_NOTIFY_CLOSED
Definition: microhttpd.h:1902
void MHD_response_queue_for_destroy(struct MHD_Response *response)
Definition: response.c:88
@ MHD_REQUEST_CLOSED
Definition: internal.h:321
#define NULL
Definition: reason_phrase.c:30
internal shared structures
@ MHD_EVENT_LOOP_INFO_CLEANUP
Definition: internal.h:249
@ MHD_YES
Definition: microhttpd.h:151
MHD_socket socket_fd
Definition: internal.h:752
struct MHD_Request request
Definition: internal.h:717
struct MHD_Daemon * daemon
Definition: internal.h:675
MHD_NotifyConnectionCallback notify_connection_cb
Definition: internal.h:1047
void * notify_connection_cb_cls
Definition: internal.h:1052
bool enable_turbo
Definition: internal.h:1490
struct MHD_Response * response
Definition: internal.h:383
enum MHD_RequestEventLoopInfo event_loop_info
Definition: internal.h:559
enum MHD_REQUEST_STATE state
Definition: internal.h:549
enum MHD_Bool(* shutdown_connection)(void *cls, struct MHD_TLS_ConnectionState *cs)