MySQL  8.0.16
Source Code Documentation
mysql_socket.h
Go to the documentation of this file.
1 /* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
2 
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6 
7 This program is also distributed with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have included with MySQL.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 
24 /**
25  @file include/mysql/psi/mysql_socket.h
26 */
27 
28 #ifndef MYSQL_SOCKET_H
29 #define MYSQL_SOCKET_H
30 
31 #include <errno.h>
32 /* For strlen() */
33 #include <string.h>
34 
35 /* For MY_STAT */
36 #include "my_dir.h"
37 #include "my_io.h"
38 /* For my_chsize */
39 #include "my_sys.h"
40 #include "mysql/psi/psi_socket.h"
41 /* For socket api */
42 #ifdef _WIN32
43 #include <MSWSock.h>
44 #ifdef WIN32_LEAN_AND_MEAN
45 #include <winsock2.h>
46 #include <ws2def.h>
47 #endif
48 #define SOCKBUF_T char
49 #else
50 #include <netinet/in.h>
51 
52 #define SOCKBUF_T void
53 #endif
54 
55 #include "my_macros.h"
57 #include "pfs_socket_provider.h"
58 
59 #ifndef PSI_SOCKET_CALL
60 #define PSI_SOCKET_CALL(M) psi_socket_service->M
61 #endif
62 
63 /**
64  @defgroup psi_api_socket Socket Instrumentation (API)
65  @ingroup psi_api
66  @{
67 */
68 
69 /**
70  @def mysql_socket_register(P1, P2, P3)
71  Socket registration.
72 */
73 #ifdef HAVE_PSI_SOCKET_INTERFACE
74 #define mysql_socket_register(P1, P2, P3) \
75  inline_mysql_socket_register(P1, P2, P3)
76 #else
77 #define mysql_socket_register(P1, P2, P3) \
78  do { \
79  } while (0)
80 #endif
81 
82 /**
83  Set socket descriptor and address.
84  @param socket instrumented socket
85  @param addr unformatted socket address
86  @param addr_len length of socket addres
87 */
88 
89 static inline void mysql_socket_set_address(
91  MYSQL_SOCKET socket, const struct sockaddr *addr, socklen_t addr_len
92 #else
93  MYSQL_SOCKET socket MY_ATTRIBUTE((unused)),
94  const struct sockaddr *addr MY_ATTRIBUTE((unused)),
95  socklen_t addr_len MY_ATTRIBUTE((unused))
96 #endif
97 ) {
98 #ifdef HAVE_PSI_SOCKET_INTERFACE
99  if (socket.m_psi != NULL) {
100  PSI_SOCKET_CALL(set_socket_info)(socket.m_psi, NULL, addr, addr_len);
101  }
102 #endif
103 }
104 
105 /**
106  Set socket descriptor and address.
107  @param socket instrumented socket
108 */
109 static inline void mysql_socket_set_thread_owner(
111  MYSQL_SOCKET socket
112 #else
113  MYSQL_SOCKET socket MY_ATTRIBUTE((unused))
114 #endif
115 ) {
116 #ifdef HAVE_PSI_SOCKET_INTERFACE
117  if (socket.m_psi != NULL) {
118  PSI_SOCKET_CALL(set_socket_thread_owner)(socket.m_psi);
119  }
120 #endif
121 }
122 
123 /**
124  MYSQL_SOCKET helper. Get socket descriptor.
125  @param mysql_socket Instrumented socket
126  @sa mysql_socket_setfd
127 */
128 static inline my_socket mysql_socket_getfd(MYSQL_SOCKET mysql_socket) {
129  return mysql_socket.fd;
130 }
131 
132 /**
133  MYSQL_SOCKET helper. Set socket descriptor.
134  @param mysql_socket Instrumented socket
135  @param fd Socket descriptor
136  @sa mysql_socket_getfd
137 */
138 static inline void mysql_socket_setfd(MYSQL_SOCKET *mysql_socket,
139  my_socket fd) {
140  if (likely(mysql_socket != NULL)) {
141  mysql_socket->fd = fd;
142  }
143 }
144 
145 /**
146  @def MYSQL_SOCKET_WAIT_VARIABLES
147  Instrumentation helper for socket waits.
148  This instrumentation declares local variables.
149  Do not use a ';' after this macro
150  @param LOCKER locker
151  @param STATE locker state
152  @sa MYSQL_START_SOCKET_WAIT.
153  @sa MYSQL_END_SOCKET_WAIT.
154 */
155 #ifdef HAVE_PSI_SOCKET_INTERFACE
156 #define MYSQL_SOCKET_WAIT_VARIABLES(LOCKER, STATE) \
157  struct PSI_socket_locker *LOCKER; \
158  PSI_socket_locker_state STATE;
159 #else
160 #define MYSQL_SOCKET_WAIT_VARIABLES(LOCKER, STATE)
161 #endif
162 
163 /**
164  @def MYSQL_START_SOCKET_WAIT
165  Instrumentation helper for socket waits.
166  This instrumentation marks the start of a wait event.
167  @param LOCKER locker
168  @param STATE locker state
169  @param SOCKET instrumented socket
170  @param OP The socket operation to be performed
171  @param COUNT bytes to be written/read
172  @sa MYSQL_END_SOCKET_WAIT.
173 */
174 #ifdef HAVE_PSI_SOCKET_INTERFACE
175 #define MYSQL_START_SOCKET_WAIT(LOCKER, STATE, SOCKET, OP, COUNT) \
176  LOCKER = inline_mysql_start_socket_wait(STATE, SOCKET, OP, COUNT, __FILE__, \
177  __LINE__)
178 #else
179 #define MYSQL_START_SOCKET_WAIT(LOCKER, STATE, SOCKET, OP, COUNT) \
180  do { \
181  } while (0)
182 #endif
183 
184 /**
185  @def MYSQL_END_SOCKET_WAIT
186  Instrumentation helper for socket waits.
187  This instrumentation marks the end of a wait event.
188  @param LOCKER locker
189  @param COUNT actual bytes written/read, or -1
190  @sa MYSQL_START_SOCKET_WAIT.
191 */
192 #ifdef HAVE_PSI_SOCKET_INTERFACE
193 #define MYSQL_END_SOCKET_WAIT(LOCKER, COUNT) \
194  inline_mysql_end_socket_wait(LOCKER, COUNT)
195 #else
196 #define MYSQL_END_SOCKET_WAIT(LOCKER, COUNT) \
197  do { \
198  } while (0)
199 #endif
200 
201 /**
202  @def MYSQL_SOCKET_SET_STATE
203  Set the state (IDLE, ACTIVE) of an instrumented socket.
204  @param SOCKET the instrumented socket
205  @param STATE the new state
206  @sa PSI_socket_state
207 */
208 #ifdef HAVE_PSI_SOCKET_INTERFACE
209 #define MYSQL_SOCKET_SET_STATE(SOCKET, STATE) \
210  inline_mysql_socket_set_state(SOCKET, STATE)
211 #else
212 #define MYSQL_SOCKET_SET_STATE(SOCKET, STATE) \
213  do { \
214  } while (0)
215 #endif
216 
217 #ifdef HAVE_PSI_SOCKET_INTERFACE
218 /**
219  Instrumentation calls for MYSQL_START_SOCKET_WAIT.
220  @sa MYSQL_START_SOCKET_WAIT.
221 */
223  PSI_socket_locker_state *state, MYSQL_SOCKET mysql_socket,
224  enum PSI_socket_operation op, size_t byte_count, const char *src_file,
225  int src_line) {
226  struct PSI_socket_locker *locker;
227  if (mysql_socket.m_psi != NULL) {
228  locker = PSI_SOCKET_CALL(start_socket_wait)(state, mysql_socket.m_psi, op,
229  byte_count, src_file, src_line);
230  } else {
231  locker = NULL;
232  }
233  return locker;
234 }
235 
236 /**
237  Instrumentation calls for MYSQL_END_SOCKET_WAIT.
238  @sa MYSQL_END_SOCKET_WAIT.
239 */
240 static inline void inline_mysql_end_socket_wait(
241  struct PSI_socket_locker *locker, size_t byte_count) {
242  if (locker != NULL) {
243  PSI_SOCKET_CALL(end_socket_wait)(locker, byte_count);
244  }
245 }
246 
247 /**
248  Set the state (IDLE, ACTIVE) of an instrumented socket.
249  @param socket the instrumented socket
250  @param state the new state
251  @sa PSI_socket_state
252 */
253 static inline void inline_mysql_socket_set_state(MYSQL_SOCKET socket,
254  enum PSI_socket_state state) {
255  if (socket.m_psi != NULL) {
256  PSI_SOCKET_CALL(set_socket_state)(socket.m_psi, state);
257  }
258 }
259 #endif /* HAVE_PSI_SOCKET_INTERFACE */
260 
261  /**
262  @def mysql_socket_socket(K, D, T, P)
263  Create a socket.
264  @c mysql_socket_socket is a replacement for @c socket.
265  @param K PSI_socket_key for this instrumented socket
266  @param D Socket domain
267  @param T Protocol type
268  @param P Transport protocol
269  */
270 
271 #ifdef HAVE_PSI_SOCKET_INTERFACE
272 #define mysql_socket_socket(K, D, T, P) inline_mysql_socket_socket(K, D, T, P)
273 #else
274 #define mysql_socket_socket(K, D, T, P) inline_mysql_socket_socket(D, T, P)
275 #endif
276 
277 /**
278  @def mysql_socket_bind(FD, AP, L)
279  Bind a socket to a local port number and IP address
280  @c mysql_socket_bind is a replacement for @c bind.
281  @param FD Instrumented socket descriptor returned by socket()
282  @param AP Pointer to local port number and IP address in sockaddr structure
283  @param L Length of sockaddr structure
284 */
285 #ifdef HAVE_PSI_SOCKET_INTERFACE
286 #define mysql_socket_bind(FD, AP, L) \
287  inline_mysql_socket_bind(__FILE__, __LINE__, FD, AP, L)
288 #else
289 #define mysql_socket_bind(FD, AP, L) inline_mysql_socket_bind(FD, AP, L)
290 #endif
291 
292 /**
293  @def mysql_socket_getsockname(FD, AP, LP)
294  Return port number and IP address of the local host
295  @c mysql_socket_getsockname is a replacement for @c getsockname.
296  @param FD Instrumented socket descriptor returned by socket()
297  @param AP Pointer to returned address of local host in @c sockaddr structure
298  @param LP Pointer to length of @c sockaddr structure
299 */
300 #ifdef HAVE_PSI_SOCKET_INTERFACE
301 #define mysql_socket_getsockname(FD, AP, LP) \
302  inline_mysql_socket_getsockname(__FILE__, __LINE__, FD, AP, LP)
303 #else
304 #define mysql_socket_getsockname(FD, AP, LP) \
305  inline_mysql_socket_getsockname(FD, AP, LP)
306 #endif
307 
308 /**
309  @def mysql_socket_connect(FD, AP, L)
310  Establish a connection to a remote host.
311  @c mysql_socket_connect is a replacement for @c connect.
312  @param FD Instrumented socket descriptor returned by socket()
313  @param AP Pointer to target address in sockaddr structure
314  @param L Length of sockaddr structure
315 */
316 #ifdef HAVE_PSI_SOCKET_INTERFACE
317 #define mysql_socket_connect(FD, AP, L) \
318  inline_mysql_socket_connect(__FILE__, __LINE__, FD, AP, L)
319 #else
320 #define mysql_socket_connect(FD, AP, L) inline_mysql_socket_connect(FD, AP, L)
321 #endif
322 
323 /**
324  @def mysql_socket_getpeername(FD, AP, LP)
325  Get port number and IP address of remote host that a socket is connected to.
326  @c mysql_socket_getpeername is a replacement for @c getpeername.
327  @param FD Instrumented socket descriptor returned by socket() or accept()
328  @param AP Pointer to returned address of remote host in sockaddr structure
329  @param LP Pointer to length of sockaddr structure
330 */
331 #ifdef HAVE_PSI_SOCKET_INTERFACE
332 #define mysql_socket_getpeername(FD, AP, LP) \
333  inline_mysql_socket_getpeername(__FILE__, __LINE__, FD, AP, LP)
334 #else
335 #define mysql_socket_getpeername(FD, AP, LP) \
336  inline_mysql_socket_getpeername(FD, AP, LP)
337 #endif
338 
339 /**
340  @def mysql_socket_send(FD, B, N, FL)
341  Send data from the buffer, B, to a connected socket.
342  @c mysql_socket_send is a replacement for @c send.
343  @param FD Instrumented socket descriptor returned by socket() or accept()
344  @param B Buffer to send
345  @param N Number of bytes to send
346  @param FL Control flags
347 */
348 #ifdef HAVE_PSI_SOCKET_INTERFACE
349 #define mysql_socket_send(FD, B, N, FL) \
350  inline_mysql_socket_send(__FILE__, __LINE__, FD, B, N, FL)
351 #else
352 #define mysql_socket_send(FD, B, N, FL) inline_mysql_socket_send(FD, B, N, FL)
353 #endif
354 
355 /**
356  @def mysql_socket_recv(FD, B, N, FL)
357  Receive data from a connected socket.
358  @c mysql_socket_recv is a replacement for @c recv.
359  @param FD Instrumented socket descriptor returned by socket() or accept()
360  @param B Buffer to receive to
361  @param N Maximum bytes to receive
362  @param FL Control flags
363 */
364 #ifdef HAVE_PSI_SOCKET_INTERFACE
365 #define mysql_socket_recv(FD, B, N, FL) \
366  inline_mysql_socket_recv(__FILE__, __LINE__, FD, B, N, FL)
367 #else
368 #define mysql_socket_recv(FD, B, N, FL) inline_mysql_socket_recv(FD, B, N, FL)
369 #endif
370 
371 /**
372  @def mysql_socket_sendto(FD, B, N, FL, AP, L)
373  Send data to a socket at the specified address.
374  @c mysql_socket_sendto is a replacement for @c sendto.
375  @param FD Instrumented socket descriptor returned by socket()
376  @param B Buffer to send
377  @param N Number of bytes to send
378  @param FL Control flags
379  @param AP Pointer to destination sockaddr structure
380  @param L Size of sockaddr structure
381 */
382 #ifdef HAVE_PSI_SOCKET_INTERFACE
383 #define mysql_socket_sendto(FD, B, N, FL, AP, L) \
384  inline_mysql_socket_sendto(__FILE__, __LINE__, FD, B, N, FL, AP, L)
385 #else
386 #define mysql_socket_sendto(FD, B, N, FL, AP, L) \
387  inline_mysql_socket_sendto(FD, B, N, FL, AP, L)
388 #endif
389 
390 /**
391  @def mysql_socket_recvfrom(FD, B, N, FL, AP, L)
392  Receive data from a socket and return source address information
393  @c mysql_socket_recvfrom is a replacement for @c recvfrom.
394  @param FD Instrumented socket descriptor returned by socket()
395  @param B Buffer to receive to
396  @param N Maximum bytes to receive
397  @param FL Control flags
398  @param AP Pointer to source address in sockaddr_storage structure
399  @param LP Size of sockaddr_storage structure
400 */
401 #ifdef HAVE_PSI_SOCKET_INTERFACE
402 #define mysql_socket_recvfrom(FD, B, N, FL, AP, LP) \
403  inline_mysql_socket_recvfrom(__FILE__, __LINE__, FD, B, N, FL, AP, LP)
404 #else
405 #define mysql_socket_recvfrom(FD, B, N, FL, AP, LP) \
406  inline_mysql_socket_recvfrom(FD, B, N, FL, AP, LP)
407 #endif
408 
409 /**
410  @def mysql_socket_getsockopt(FD, LV, ON, OP, OL)
411  Get a socket option for the specified socket.
412  @c mysql_socket_getsockopt is a replacement for @c getsockopt.
413  @param FD Instrumented socket descriptor returned by socket()
414  @param LV Protocol level
415  @param ON Option to query
416  @param OP Buffer which will contain the value for the requested option
417  @param OL Pointer to length of OP
418 */
419 #ifdef HAVE_PSI_SOCKET_INTERFACE
420 #define mysql_socket_getsockopt(FD, LV, ON, OP, OL) \
421  inline_mysql_socket_getsockopt(__FILE__, __LINE__, FD, LV, ON, OP, OL)
422 #else
423 #define mysql_socket_getsockopt(FD, LV, ON, OP, OL) \
424  inline_mysql_socket_getsockopt(FD, LV, ON, OP, OL)
425 #endif
426 
427 /**
428  @def mysql_socket_setsockopt(FD, LV, ON, OP, OL)
429  Set a socket option for the specified socket.
430  @c mysql_socket_setsockopt is a replacement for @c setsockopt.
431  @param FD Instrumented socket descriptor returned by socket()
432  @param LV Protocol level
433  @param ON Option to modify
434  @param OP Buffer containing the value for the specified option
435  @param OL Pointer to length of OP
436 */
437 #ifdef HAVE_PSI_SOCKET_INTERFACE
438 #define mysql_socket_setsockopt(FD, LV, ON, OP, OL) \
439  inline_mysql_socket_setsockopt(__FILE__, __LINE__, FD, LV, ON, OP, OL)
440 #else
441 #define mysql_socket_setsockopt(FD, LV, ON, OP, OL) \
442  inline_mysql_socket_setsockopt(FD, LV, ON, OP, OL)
443 #endif
444 
445 /**
446  @def mysql_sock_set_nonblocking
447  Set socket to non-blocking.
448  @param FD instrumented socket descriptor
449 */
450 #ifdef HAVE_PSI_SOCKET_INTERFACE
451 #define mysql_sock_set_nonblocking(FD) \
452  inline_mysql_sock_set_nonblocking(__FILE__, __LINE__, FD)
453 #else
454 #define mysql_sock_set_nonblocking(FD) inline_mysql_sock_set_nonblocking(FD)
455 #endif
456 
457 /**
458  @def mysql_socket_listen(FD, N)
459  Set socket state to listen for an incoming connection.
460  @c mysql_socket_listen is a replacement for @c listen.
461  @param FD Instrumented socket descriptor, bound and connected
462  @param N Maximum number of pending connections allowed.
463 */
464 #ifdef HAVE_PSI_SOCKET_INTERFACE
465 #define mysql_socket_listen(FD, N) \
466  inline_mysql_socket_listen(__FILE__, __LINE__, FD, N)
467 #else
468 #define mysql_socket_listen(FD, N) inline_mysql_socket_listen(FD, N)
469 #endif
470 
471 /**
472  @def mysql_socket_accept(K, FD, AP, LP)
473  Accept a connection from any remote host; TCP only.
474  @c mysql_socket_accept is a replacement for @c accept.
475  @param K PSI_socket_key for this instrumented socket
476  @param FD Instrumented socket descriptor, bound and placed in a listen state
477  @param AP Pointer to sockaddr structure with returned IP address and port of
478  connected host
479  @param LP Pointer to length of valid information in AP
480 */
481 #ifdef HAVE_PSI_SOCKET_INTERFACE
482 #define mysql_socket_accept(K, FD, AP, LP) \
483  inline_mysql_socket_accept(__FILE__, __LINE__, K, FD, AP, LP)
484 #else
485 #define mysql_socket_accept(K, FD, AP, LP) \
486  inline_mysql_socket_accept(FD, AP, LP)
487 #endif
488 
489 /**
490  @def mysql_socket_close(FD)
491  Close a socket and sever any connections.
492  @c mysql_socket_close is a replacement for @c close.
493  @param FD Instrumented socket descriptor returned by socket() or accept()
494 */
495 #ifdef HAVE_PSI_SOCKET_INTERFACE
496 #define mysql_socket_close(FD) inline_mysql_socket_close(__FILE__, __LINE__, FD)
497 #else
498 #define mysql_socket_close(FD) inline_mysql_socket_close(FD)
499 #endif
500 
501 /**
502  @def mysql_socket_shutdown(FD, H)
503  Disable receives and/or sends on a socket.
504  @c mysql_socket_shutdown is a replacement for @c shutdown.
505  @param FD Instrumented socket descriptor returned by socket() or accept()
506  @param H Specifies which operations to shutdown
507 */
508 #ifdef HAVE_PSI_SOCKET_INTERFACE
509 #define mysql_socket_shutdown(FD, H) \
510  inline_mysql_socket_shutdown(__FILE__, __LINE__, FD, H)
511 #else
512 #define mysql_socket_shutdown(FD, H) inline_mysql_socket_shutdown(FD, H)
513 #endif
514 
515 #ifdef HAVE_PSI_SOCKET_INTERFACE
516 static inline void inline_mysql_socket_register(const char *category,
518  int count) {
519  PSI_SOCKET_CALL(register_socket)(category, info, count);
520 }
521 #endif
522 
523 /** mysql_socket_socket */
524 
528 #endif
529  int domain, int type, int protocol) {
530  MYSQL_SOCKET mysql_socket = MYSQL_INVALID_SOCKET;
531  mysql_socket.fd = socket(domain, type, protocol);
532 
533 #ifdef HAVE_PSI_SOCKET_INTERFACE
534  if (likely(mysql_socket.fd != INVALID_SOCKET)) {
535  mysql_socket.m_psi = PSI_SOCKET_CALL(init_socket)(
536  key, (const my_socket *)&mysql_socket.fd, NULL, 0);
537  }
538 #endif
539  return mysql_socket;
540 }
541 
542 /** mysql_socket_bind */
543 
544 static inline int inline_mysql_socket_bind(
546  const char *src_file, uint src_line,
547 #endif
548  MYSQL_SOCKET mysql_socket, const struct sockaddr *addr, socklen_t len) {
549  int result;
550 
551 #ifdef HAVE_PSI_SOCKET_INTERFACE
552  if (mysql_socket.m_psi != NULL) {
553  /* Instrumentation start */
555  PSI_socket_locker *locker;
556  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
557  PSI_SOCKET_BIND, (size_t)0,
558  src_file, src_line);
559 
560  /* Instrumented code */
561  result = bind(mysql_socket.fd, addr, len);
562 
563  /* Instrumentation end */
564  if (result == 0) {
565  PSI_SOCKET_CALL(set_socket_info)(mysql_socket.m_psi, NULL, addr, len);
566  }
567 
568  if (locker != NULL) {
569  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
570  }
571 
572  return result;
573  }
574 #endif
575 
576  /* Non instrumented code */
577  result = bind(mysql_socket.fd, addr, len);
578  return result;
579 }
580 
581 /** mysql_socket_getsockname */
582 
585  const char *src_file, uint src_line,
586 #endif
587  MYSQL_SOCKET mysql_socket, struct sockaddr *addr, socklen_t *len) {
588  int result;
589 
590 #ifdef HAVE_PSI_SOCKET_INTERFACE
591  if (mysql_socket.m_psi != NULL) {
592  /* Instrumentation start */
593  PSI_socket_locker *locker;
595  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
596  PSI_SOCKET_BIND, (size_t)0,
597  src_file, src_line);
598 
599  /* Instrumented code */
600  result = getsockname(mysql_socket.fd, addr, len);
601 
602  /* Instrumentation end */
603  if (locker != NULL) {
604  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
605  }
606 
607  return result;
608  }
609 #endif
610 
611  /* Non instrumented code */
612  result = getsockname(mysql_socket.fd, addr, len);
613 
614  return result;
615 }
616 
617 /** mysql_socket_connect */
618 
619 static inline int inline_mysql_socket_connect(
621  const char *src_file, uint src_line,
622 #endif
623  MYSQL_SOCKET mysql_socket, const struct sockaddr *addr, socklen_t len) {
624  int result;
625 
626 #ifdef HAVE_PSI_SOCKET_INTERFACE
627  if (mysql_socket.m_psi != NULL) {
628  /* Instrumentation start */
629  PSI_socket_locker *locker;
631  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
632  PSI_SOCKET_CONNECT, (size_t)0,
633  src_file, src_line);
634 
635  /* Instrumented code */
636  result = connect(mysql_socket.fd, addr, len);
637 
638  /* Instrumentation end */
639  if (locker != NULL) {
640  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
641  }
642 
643  return result;
644  }
645 #endif
646 
647  /* Non instrumented code */
648  result = connect(mysql_socket.fd, addr, len);
649 
650  return result;
651 }
652 
653 /** mysql_socket_getpeername */
654 
657  const char *src_file, uint src_line,
658 #endif
659  MYSQL_SOCKET mysql_socket, struct sockaddr *addr, socklen_t *len) {
660  int result;
661 
662 #ifdef HAVE_PSI_SOCKET_INTERFACE
663  if (mysql_socket.m_psi != NULL) {
664  /* Instrumentation start */
665  PSI_socket_locker *locker;
667  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
668  PSI_SOCKET_BIND, (size_t)0,
669  src_file, src_line);
670 
671  /* Instrumented code */
672  result = getpeername(mysql_socket.fd, addr, len);
673 
674  /* Instrumentation end */
675  if (locker != NULL) {
676  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
677  }
678 
679  return result;
680  }
681 #endif
682 
683  /* Non instrumented code */
684  result = getpeername(mysql_socket.fd, addr, len);
685 
686  return result;
687 }
688 
689 /** mysql_socket_send */
690 
691 static inline ssize_t inline_mysql_socket_send(
693  const char *src_file, uint src_line,
694 #endif
695  MYSQL_SOCKET mysql_socket, const SOCKBUF_T *buf, size_t n, int flags) {
696  ssize_t result;
697 
698 #ifdef HAVE_PSI_SOCKET_INTERFACE
699  if (mysql_socket.m_psi != NULL) {
700  /* Instrumentation start */
701  PSI_socket_locker *locker;
703  locker = PSI_SOCKET_CALL(start_socket_wait)(
704  &state, mysql_socket.m_psi, PSI_SOCKET_SEND, n, src_file, src_line);
705 
706  /* Instrumented code */
707  result = send(mysql_socket.fd, buf, IF_WIN((int), ) n, flags);
708 
709  /* Instrumentation end */
710  if (locker != NULL) {
711  size_t bytes_written;
712  bytes_written = (result > -1) ? result : 0;
713  PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_written);
714  }
715 
716  return result;
717  }
718 #endif
719 
720  /* Non instrumented code */
721  result = send(mysql_socket.fd, buf, IF_WIN((int), ) n, flags);
722 
723  return result;
724 }
725 
726 /** mysql_socket_recv */
727 
728 static inline ssize_t inline_mysql_socket_recv(
730  const char *src_file, uint src_line,
731 #endif
732  MYSQL_SOCKET mysql_socket, SOCKBUF_T *buf, size_t n, int flags) {
733  ssize_t result;
734 
735 #ifdef HAVE_PSI_SOCKET_INTERFACE
736  if (mysql_socket.m_psi != NULL) {
737  /* Instrumentation start */
738  PSI_socket_locker *locker;
740  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
741  PSI_SOCKET_RECV, (size_t)0,
742  src_file, src_line);
743 
744  /* Instrumented code */
745  result = recv(mysql_socket.fd, buf, IF_WIN((int), ) n, flags);
746 
747  /* Instrumentation end */
748  if (locker != NULL) {
749  size_t bytes_read;
750  bytes_read = (result > -1) ? result : 0;
751  PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_read);
752  }
753 
754  return result;
755  }
756 #endif
757 
758  /* Non instrumented code */
759  result = recv(mysql_socket.fd, buf, IF_WIN((int), ) n, flags);
760 
761  return result;
762 }
763 
764 /** mysql_socket_sendto */
765 
766 static inline ssize_t inline_mysql_socket_sendto(
768  const char *src_file, uint src_line,
769 #endif
770  MYSQL_SOCKET mysql_socket, const SOCKBUF_T *buf, size_t n, int flags,
771  const struct sockaddr *addr, socklen_t addr_len) {
772  ssize_t result;
773 
774 #ifdef HAVE_PSI_SOCKET_INTERFACE
775  if (mysql_socket.m_psi != NULL) {
776  /* Instrumentation start */
777  PSI_socket_locker *locker;
779  locker = PSI_SOCKET_CALL(start_socket_wait)(
780  &state, mysql_socket.m_psi, PSI_SOCKET_SEND, n, src_file, src_line);
781 
782  /* Instrumented code */
783  result =
784  sendto(mysql_socket.fd, buf, IF_WIN((int), ) n, flags, addr, addr_len);
785 
786  /* Instrumentation end */
787  if (locker != NULL) {
788  size_t bytes_written;
789  bytes_written = (result > -1) ? result : 0;
790  PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_written);
791  }
792 
793  return result;
794  }
795 #endif
796 
797  /* Non instrumented code */
798  result =
799  sendto(mysql_socket.fd, buf, IF_WIN((int), ) n, flags, addr, addr_len);
800 
801  return result;
802 }
803 
804 /** mysql_socket_recvfrom */
805 
806 static inline ssize_t inline_mysql_socket_recvfrom(
808  const char *src_file, uint src_line,
809 #endif
810  MYSQL_SOCKET mysql_socket, SOCKBUF_T *buf, size_t n, int flags,
811  struct sockaddr *addr, socklen_t *addr_len) {
812  ssize_t result;
813 
814 #ifdef HAVE_PSI_SOCKET_INTERFACE
815  if (mysql_socket.m_psi != NULL) {
816  /* Instrumentation start */
817  PSI_socket_locker *locker;
819  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
820  PSI_SOCKET_RECV, (size_t)0,
821  src_file, src_line);
822 
823  /* Instrumented code */
824  result = recvfrom(mysql_socket.fd, buf, IF_WIN((int), ) n, flags, addr,
825  addr_len);
826 
827  /* Instrumentation end */
828  if (locker != NULL) {
829  size_t bytes_read;
830  bytes_read = (result > -1) ? result : 0;
831  PSI_SOCKET_CALL(end_socket_wait)(locker, bytes_read);
832  }
833 
834  return result;
835  }
836 #endif
837 
838  /* Non instrumented code */
839  result =
840  recvfrom(mysql_socket.fd, buf, IF_WIN((int), ) n, flags, addr, addr_len);
841 
842  return result;
843 }
844 
845 /** mysql_socket_getsockopt */
846 
849  const char *src_file, uint src_line,
850 #endif
851  MYSQL_SOCKET mysql_socket, int level, int optname, SOCKBUF_T *optval,
852  socklen_t *optlen) {
853  int result;
854 
855 #ifdef HAVE_PSI_SOCKET_INTERFACE
856  if (mysql_socket.m_psi != NULL) {
857  /* Instrumentation start */
858  PSI_socket_locker *locker;
860  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
861  PSI_SOCKET_OPT, (size_t)0,
862  src_file, src_line);
863 
864  /* Instrumented code */
865  result = getsockopt(mysql_socket.fd, level, optname, optval, optlen);
866 
867  /* Instrumentation end */
868  if (locker != NULL) {
869  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
870  }
871 
872  return result;
873  }
874 #endif
875 
876  /* Non instrumented code */
877  result = getsockopt(mysql_socket.fd, level, optname, optval, optlen);
878 
879  return result;
880 }
881 
882 /** mysql_socket_setsockopt */
883 
886  const char *src_file, uint src_line,
887 #endif
888  MYSQL_SOCKET mysql_socket, int level, int optname, const SOCKBUF_T *optval,
889  socklen_t optlen) {
890  int result;
891 
892 #ifdef HAVE_PSI_SOCKET_INTERFACE
893  if (mysql_socket.m_psi) {
894  /* Instrumentation start */
895  PSI_socket_locker *locker;
897  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
898  PSI_SOCKET_OPT, (size_t)0,
899  src_file, src_line);
900 
901  /* Instrumented code */
902  result = setsockopt(mysql_socket.fd, level, optname, optval, optlen);
903 
904  /* Instrumentation end */
905  if (locker != NULL) {
906  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
907  }
908 
909  return result;
910  }
911 #endif
912 
913  /* Non instrumented code */
914  result = setsockopt(mysql_socket.fd, level, optname, optval, optlen);
915 
916  return result;
917 }
918 
919 /** set_socket_nonblock */
920 static inline int set_socket_nonblock(my_socket fd) {
921  int ret = 0;
922 #ifdef _WIN32
923  {
924  u_long nonblocking = 1;
925  ret = ioctlsocket(fd, FIONBIO, &nonblocking);
926  }
927 #else
928  {
929  int fd_flags;
930  fd_flags = fcntl(fd, F_GETFL, 0);
931  if (fd_flags < 0) {
932  return errno;
933  }
934 #if defined(O_NONBLOCK)
935  fd_flags |= O_NONBLOCK;
936 #elif defined(O_NDELAY)
937  fd_flags |= O_NDELAY;
938 #elif defined(O_FNDELAY)
939  fd_flags |= O_FNDELAY;
940 #else
941 #error "No definition of non-blocking flag found."
942 #endif /* O_NONBLOCK */
943  if (fcntl(fd, F_SETFL, fd_flags) == -1) {
944  ret = errno;
945  }
946  }
947 #endif /* _WIN32 */
948  return ret;
949 }
950 
951 /** mysql_socket_set_nonblocking */
952 
955  const char *src_file, uint src_line,
956 #endif
957  MYSQL_SOCKET mysql_socket) {
958  int result = 0;
959 
960 #ifdef HAVE_PSI_SOCKET_INTERFACE
961  if (mysql_socket.m_psi) {
962  /* Instrumentation start */
963  PSI_socket_locker *locker;
965  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
966  PSI_SOCKET_OPT, (size_t)0,
967  src_file, src_line);
968 
969  /* Instrumented code */
970  result = set_socket_nonblock(mysql_socket.fd);
971 
972  /* Instrumentation end */
973  if (locker != NULL) {
974  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
975  }
976 
977  return result;
978  }
979 #endif
980 
981  /* Non instrumented code */
982  result = set_socket_nonblock(mysql_socket.fd);
983 
984  return result;
985 }
986 
987 /** mysql_socket_listen */
988 
989 static inline int inline_mysql_socket_listen(
991  const char *src_file, uint src_line,
992 #endif
993  MYSQL_SOCKET mysql_socket, int backlog) {
994  int result;
995 
996 #ifdef HAVE_PSI_SOCKET_INTERFACE
997  if (mysql_socket.m_psi != NULL) {
998  /* Instrumentation start */
999  PSI_socket_locker *locker;
1001  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
1002  PSI_SOCKET_CONNECT, (size_t)0,
1003  src_file, src_line);
1004 
1005  /* Instrumented code */
1006  result = listen(mysql_socket.fd, backlog);
1007 
1008  /* Instrumentation end */
1009  if (locker != NULL) {
1010  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
1011  }
1012 
1013  return result;
1014  }
1015 #endif
1016 
1017  /* Non instrumented code */
1018  result = listen(mysql_socket.fd, backlog);
1019 
1020  return result;
1021 }
1022 
1023 /** mysql_socket_accept */
1024 
1027  const char *src_file, uint src_line, PSI_socket_key key,
1028 #endif
1029  MYSQL_SOCKET socket_listen, struct sockaddr *addr, socklen_t *addr_len) {
1030  MYSQL_SOCKET socket_accept = MYSQL_INVALID_SOCKET;
1031  socklen_t addr_length = (addr_len != NULL) ? *addr_len : 0;
1032 
1033 #ifdef HAVE_PSI_SOCKET_INTERFACE
1034  if (socket_listen.m_psi != NULL) {
1035  /* Instrumentation start */
1036  PSI_socket_locker *locker;
1038  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, socket_listen.m_psi,
1039  PSI_SOCKET_CONNECT, (size_t)0,
1040  src_file, src_line);
1041 
1042  /* Instrumented code */
1043  socket_accept.fd = accept(socket_listen.fd, addr, &addr_length);
1044 
1045  /* Instrumentation end */
1046  if (locker != NULL) {
1047  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
1048  }
1049  } else
1050 #endif
1051  {
1052  /* Non instrumented code */
1053  socket_accept.fd = accept(socket_listen.fd, addr, &addr_length);
1054  }
1055 
1056 #ifdef HAVE_PSI_SOCKET_INTERFACE
1057  if (likely(socket_accept.fd != INVALID_SOCKET)) {
1058  /* Initialize the instrument with the new socket descriptor and address */
1059  socket_accept.m_psi = PSI_SOCKET_CALL(init_socket)(
1060  key, (const my_socket *)&socket_accept.fd, addr, addr_length);
1061  }
1062 #endif
1063 
1064  return socket_accept;
1065 }
1066 
1067 /** mysql_socket_close */
1068 
1069 static inline int inline_mysql_socket_close(
1071  const char *src_file, uint src_line,
1072 #endif
1073  MYSQL_SOCKET mysql_socket) {
1074  int result;
1075 
1076 #ifdef HAVE_PSI_SOCKET_INTERFACE
1077  if (mysql_socket.m_psi != NULL) {
1078  /* Instrumentation start */
1079  PSI_socket_locker *locker;
1081  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
1082  PSI_SOCKET_CLOSE, (size_t)0,
1083  src_file, src_line);
1084 
1085  /* Instrumented code */
1086  result = closesocket(mysql_socket.fd);
1087 
1088  /* Instrumentation end */
1089  if (locker != NULL) {
1090  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
1091  }
1092  /* Remove the instrumentation for this socket. */
1093  if (mysql_socket.m_psi != NULL) {
1094  PSI_SOCKET_CALL(destroy_socket)(mysql_socket.m_psi);
1095  }
1096 
1097  return result;
1098  }
1099 #endif
1100 
1101  /* Non instrumented code */
1102  result = closesocket(mysql_socket.fd);
1103 
1104  return result;
1105 }
1106 
1107 /** mysql_socket_shutdown */
1108 
1111  const char *src_file, uint src_line,
1112 #endif
1113  MYSQL_SOCKET mysql_socket, int how) {
1114  int result;
1115 
1116 #ifdef _WIN32
1117  static LPFN_DISCONNECTEX DisconnectEx = NULL;
1118  if (DisconnectEx == NULL) {
1119  DWORD dwBytesReturned;
1120  GUID guidDisconnectEx = WSAID_DISCONNECTEX;
1121  WSAIoctl(mysql_socket.fd, SIO_GET_EXTENSION_FUNCTION_POINTER,
1122  &guidDisconnectEx, sizeof(GUID), &DisconnectEx,
1123  sizeof(DisconnectEx), &dwBytesReturned, NULL, NULL);
1124  }
1125 #endif
1126 
1127 /* Instrumentation start */
1128 #ifdef HAVE_PSI_SOCKET_INTERFACE
1129  if (mysql_socket.m_psi != NULL) {
1130  PSI_socket_locker *locker;
1132  locker = PSI_SOCKET_CALL(start_socket_wait)(&state, mysql_socket.m_psi,
1133  PSI_SOCKET_SHUTDOWN, (size_t)0,
1134  src_file, src_line);
1135 
1136 /* Instrumented code */
1137 #ifdef _WIN32
1138  if (DisconnectEx)
1139  result = (DisconnectEx(mysql_socket.fd, (LPOVERLAPPED)NULL, (DWORD)0,
1140  (DWORD)0) == TRUE)
1141  ? 0
1142  : -1;
1143  else
1144 #endif
1145  result = shutdown(mysql_socket.fd, how);
1146 
1147  /* Instrumentation end */
1148  if (locker != NULL) {
1149  PSI_SOCKET_CALL(end_socket_wait)(locker, (size_t)0);
1150  }
1151 
1152  return result;
1153  }
1154 #endif
1155 
1156 /* Non instrumented code */
1157 #ifdef _WIN32
1158  if (DisconnectEx)
1159  result = (DisconnectEx(mysql_socket.fd, (LPOVERLAPPED)NULL, (DWORD)0,
1160  (DWORD)0) == TRUE)
1161  ? 0
1162  : -1;
1163  else
1164 #endif
1165  result = shutdown(mysql_socket.fd, how);
1166 
1167  return result;
1168 }
1169 
1170  /** @} (end of group psi_api_socket) */
1171 
1172 #endif
Socket close, as in shutdown().
Definition: psi_socket_bits.h:95
Some common macros.
#define F_GETFL
Definition: win32.h:37
Socket receive, recv().
Definition: psi_socket_bits.h:99
#define recv(a, b, c, d)
Definition: win32.h:152
Socket options, as in getsockopt() and setsockopt().
Definition: psi_socket_bits.h:111
ssize_t count
Definition: memcached.c:386
static struct PSI_socket_locker * inline_mysql_start_socket_wait(PSI_socket_locker_state *state, MYSQL_SOCKET mysql_socket, enum PSI_socket_operation op, size_t byte_count, const char *src_file, int src_line)
Instrumentation calls for MYSQL_START_SOCKET_WAIT.
Definition: mysql_socket.h:222
Performance schema instrumentation (declarations).
static void mysql_socket_set_address(MYSQL_SOCKET socket, const struct sockaddr *addr, socklen_t addr_len)
Set socket descriptor and address.
Definition: mysql_socket.h:89
static ssize_t inline_mysql_socket_recv(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, SOCKBUF_T *buf, size_t n, int flags)
mysql_socket_recv
Definition: mysql_socket.h:728
static MYSQL_SOCKET inline_mysql_socket_accept(const char *src_file, uint src_line, PSI_socket_key key, MYSQL_SOCKET socket_listen, struct sockaddr *addr, socklen_t *addr_len)
mysql_socket_accept
Definition: mysql_socket.h:1025
Sergei Dialog Client Authentication NULL
Definition: dialog.cc:352
static int inline_mysql_socket_getpeername(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, struct sockaddr *addr, socklen_t *len)
mysql_socket_getpeername
Definition: mysql_socket.h:655
Socket send, send().
Definition: psi_socket_bits.h:97
struct PSI_socket_locker PSI_socket_locker
Definition: psi_socket_bits.h:75
protocol
Definition: memcached.h:112
#define MYSQL_INVALID_SOCKET
MYSQL_SOCKET initial value.
Definition: mysql_socket_bits.h:51
Socket shutdown, as in shutdown().
Definition: psi_socket_bits.h:115
static ssize_t inline_mysql_socket_recvfrom(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, SOCKBUF_T *buf, size_t n, int flags, struct sockaddr *addr, socklen_t *addr_len)
mysql_socket_recvfrom
Definition: mysql_socket.h:806
static int inline_mysql_socket_connect(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, const struct sockaddr *addr, socklen_t len)
mysql_socket_connect
Definition: mysql_socket.h:619
PSI_socket_operation
Operation performed on an instrumented socket.
Definition: psi_socket_bits.h:87
static void inline_mysql_socket_set_state(MYSQL_SOCKET socket, enum PSI_socket_state state)
Set the state (IDLE, ACTIVE) of an instrumented socket.
Definition: mysql_socket.h:253
static void inline_mysql_end_socket_wait(struct PSI_socket_locker *locker, size_t byte_count)
Instrumentation calls for MYSQL_END_SOCKET_WAIT.
Definition: mysql_socket.h:240
struct PSI_socket * m_psi
The instrumentation hook.
Definition: mysql_socket_bits.h:43
#define F_SETFL
Definition: win32.h:38
static ssize_t inline_mysql_socket_sendto(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, const SOCKBUF_T *buf, size_t n, int flags, const struct sockaddr *addr, socklen_t addr_len)
mysql_socket_sendto
Definition: mysql_socket.h:766
Socket instrument information.
Definition: psi_socket_bits.h:126
static int inline_mysql_sock_set_nonblocking(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket)
mysql_socket_set_nonblocking
Definition: mysql_socket.h:953
unsigned int PSI_socket_key
Instrumented socket key.
Definition: psi_socket_bits.h:47
static void inline_mysql_socket_register(const char *category, PSI_socket_info *info, int count)
Definition: mysql_socket.h:516
static int inline_mysql_socket_setsockopt(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, int level, int optname, const SOCKBUF_T *optval, socklen_t optlen)
mysql_socket_setsockopt
Definition: mysql_socket.h:884
static int inline_mysql_socket_getsockname(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, struct sockaddr *addr, socklen_t *len)
mysql_socket_getsockname
Definition: mysql_socket.h:583
void destroy_socket(PFS_socket *pfs)
Destroy instrumentation for a socket instance.
Definition: pfs_instr.cc:1324
bool shutdown()
Shuts down the data dictionary instance by deleting the instance of dd::Dictionary_impl* upon server ...
Definition: dd.cc:70
static int inline_mysql_socket_listen(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, int backlog)
mysql_socket_listen
Definition: mysql_socket.h:989
unsigned int len
Definition: dbug_analyze.cc:216
#define closesocket(A)
Definition: my_io.h:172
unsigned int uint
Definition: uca-dump.cc:29
Socket connection, as in connect(), listen() and accept().
Definition: psi_socket_bits.h:91
State data storage for start_socket_wait_v1_t.
Definition: psi_socket_bits.h:156
Socket bind, as in bind(), getsockname() and getpeername().
Definition: psi_socket_bits.h:93
static ssize_t inline_mysql_socket_send(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, const SOCKBUF_T *buf, size_t n, int flags)
mysql_socket_send
Definition: mysql_socket.h:691
Performance schema instrumentation interface.
int my_socket
Definition: my_io_bits.h:59
bool likely(bool expr)
Definition: my_compiler.h:64
Common header for many mysys elements.
An instrumented socket.
Definition: mysql_socket_bits.h:34
static const char * key
Definition: suite_stubs.c:14
static const char * category
Definition: sha2_password.cc:168
static MYSQL_SOCKET inline_mysql_socket_socket(PSI_socket_key key, int domain, int type, int protocol)
mysql_socket_socket
Definition: mysql_socket.h:525
static int inline_mysql_socket_getsockopt(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, int level, int optname, SOCKBUF_T *optval, socklen_t *optlen)
mysql_socket_getsockopt
Definition: mysql_socket.h:847
int type
Definition: http_common.h:411
#define SOCKBUF_T
Definition: mysql_socket.h:52
static int set_socket_nonblock(my_socket fd)
set_socket_nonblock
Definition: mysql_socket.h:920
Common #defines and includes for file and socket I/O.
#define PSI_SOCKET_CALL(M)
Definition: psi_socket.h:31
#define O_NONBLOCK
Definition: win32.h:36
my_socket fd
The real socket descriptor.
Definition: mysql_socket_bits.h:36
PSI_socket_state
State of an instrumented socket.
Definition: psi_socket_bits.h:78
#define HAVE_PSI_SOCKET_INTERFACE
Definition: my_psi_config.h:194
static int inline_mysql_socket_bind(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, const struct sockaddr *addr, socklen_t len)
mysql_socket_bind
Definition: mysql_socket.h:544
Log info(cout, "NOTE")
static void mysql_socket_set_thread_owner(MYSQL_SOCKET socket)
Set socket descriptor and address.
Definition: mysql_socket.h:109
static int flags[50]
Definition: hp_test1.cc:39
static void mysql_socket_setfd(MYSQL_SOCKET *mysql_socket, my_socket fd)
MYSQL_SOCKET helper.
Definition: mysql_socket.h:138
static my_socket mysql_socket_getfd(MYSQL_SOCKET mysql_socket)
MYSQL_SOCKET helper.
Definition: mysql_socket.h:128
static int inline_mysql_socket_shutdown(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket, int how)
mysql_socket_shutdown
Definition: mysql_socket.h:1109
#define IF_WIN(A, B)
Definition: my_macros.h:50
#define INVALID_SOCKET
Definition: my_io.h:184
static int inline_mysql_socket_close(const char *src_file, uint src_line, MYSQL_SOCKET mysql_socket)
mysql_socket_close
Definition: mysql_socket.h:1069