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