grpc
third_party
cares
cares
src
lib
ares__close_sockets.c
Go to the documentation of this file.
1
2
/* Copyright 1998 by the Massachusetts Institute of Technology.
3
*
4
* Permission to use, copy, modify, and distribute this
5
* software and its documentation for any purpose and without
6
* fee is hereby granted, provided that the above copyright
7
* notice appear in all copies and that both that copyright
8
* notice and this permission notice appear in supporting
9
* documentation, and that the name of M.I.T. not be used in
10
* advertising or publicity pertaining to distribution of the
11
* software without specific, written prior permission.
12
* M.I.T. makes no representations about the suitability of
13
* this software for any purpose. It is provided "as is"
14
* without express or implied warranty.
15
*/
16
17
#include "
ares_setup.h
"
18
19
#include "
ares.h
"
20
#include "
ares_private.h
"
21
22
void
ares__close_sockets
(
ares_channel
channel
,
struct
server_state
*
server
)
23
{
24
struct
send_request
*sendreq;
25
26
/* Free all pending output buffers. */
27
while
(
server
->qhead)
28
{
29
/* Advance server->qhead; pull out query as we go. */
30
sendreq =
server
->qhead;
31
server
->qhead = sendreq->
next
;
32
if
(sendreq->
data_storage
!= NULL)
33
ares_free
(sendreq->
data_storage
);
34
ares_free
(sendreq);
35
}
36
server
->qtail = NULL;
37
38
/* Reset any existing input buffer. */
39
if
(
server
->tcp_buffer)
40
ares_free
(
server
->tcp_buffer);
41
server
->tcp_buffer = NULL;
42
server
->tcp_lenbuf_pos = 0;
43
44
/* Reset brokenness */
45
server
->is_broken = 0;
46
47
/* Close the TCP and UDP sockets. */
48
if
(
server
->tcp_socket !=
ARES_SOCKET_BAD
)
49
{
50
SOCK_STATE_CALLBACK
(
channel
,
server
->tcp_socket, 0, 0);
51
ares__close_socket
(
channel
,
server
->tcp_socket);
52
server
->tcp_socket =
ARES_SOCKET_BAD
;
53
server
->tcp_connection_generation = ++
channel
->tcp_connection_generation;
54
}
55
if
(
server
->udp_socket !=
ARES_SOCKET_BAD
)
56
{
57
SOCK_STATE_CALLBACK
(
channel
,
server
->udp_socket, 0, 0);
58
ares__close_socket
(
channel
,
server
->udp_socket);
59
server
->udp_socket =
ARES_SOCKET_BAD
;
60
}
61
}
ares__close_sockets
void ares__close_sockets(ares_channel channel, struct server_state *server)
Definition:
ares__close_sockets.c:22
server_state
Definition:
ares_private.h:161
ares.h
send_request
Definition:
ares_private.h:147
send_request::next
struct send_request * next
Definition:
ares_private.h:158
channel
wrapped_grpc_channel * channel
Definition:
src/php/ext/grpc/call.h:33
send_request::data_storage
unsigned char * data_storage
Definition:
ares_private.h:155
SOCK_STATE_CALLBACK
#define SOCK_STATE_CALLBACK(c, s, r, w)
Definition:
ares_private.h:416
ares_setup.h
ARES_SOCKET_BAD
#define ARES_SOCKET_BAD
Definition:
ares.h:230
ares_channeldata
Definition:
ares_private.h:266
ares__close_socket
void ares__close_socket(ares_channel, ares_socket_t)
Definition:
ares_process.c:1542
server
Definition:
examples/python/async_streaming/server.py:1
ares_free
void(* ares_free)(void *ptr)=default_free
Definition:
ares_library_init.c:60
ares_private.h
grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:43