The world's most popular open source database
#include "my_net.h"Include dependency graph for violite.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Classes | |
| struct | st_vio |
Defines | |
| #define | VIO_LOCALHOST 1 |
| #define | VIO_BUFFERED_READ 2 |
| #define | VIO_READ_BUFFER_SIZE 16384 |
| #define | HANDLE void * |
| #define | vio_delete(vio) (vio)->viodelete(vio) |
| #define | vio_errno(vio) (vio)->vioerrno(vio) |
| #define | vio_read(vio, buf, size) ((vio)->read)(vio,buf,size) |
| #define | vio_write(vio, buf, size) ((vio)->write)(vio, buf, size) |
| #define | vio_blocking(vio, set_blocking_mode, old_mode) (vio)->vioblocking(vio, set_blocking_mode, old_mode) |
| #define | vio_is_blocking(vio) (vio)->is_blocking(vio) |
| #define | vio_fastsend(vio) (vio)->fastsend(vio) |
| #define | vio_keepalive(vio, set_keep_alive) (vio)->viokeepalive(vio, set_keep_alive) |
| #define | vio_should_retry(vio) (vio)->should_retry(vio) |
| #define | vio_was_interrupted(vio) (vio)->was_interrupted(vio) |
| #define | vio_close(vio) ((vio)->vioclose)(vio) |
| #define | vio_peer_addr(vio, buf, prt) (vio)->peer_addr(vio, buf, prt) |
| #define | vio_in_addr(vio, in) (vio)->in_addr(vio, in) |
| #define | vio_timeout(vio, which, seconds) (vio)->timeout(vio, which, seconds) |
Enumerations | |
| enum | enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL, VIO_TYPE_SHARED_MEMORY } |
| enum | SSL_type { SSL_TYPE_NOT_SPECIFIED = -1, SSL_TYPE_NONE, SSL_TYPE_ANY, SSL_TYPE_X509, SSL_TYPE_SPECIFIED } |
Functions | |
| Vio * | vio_new (my_socket sd, enum enum_vio_type type, uint flags) |
| void | vio_delete (Vio *vio) |
| int | vio_close (Vio *vio) |
| void | vio_reset (Vio *vio, enum enum_vio_type type, my_socket sd, HANDLE hPipe, uint flags) |
| int | vio_read (Vio *vio, gptr buf, int size) |
| int | vio_read_buff (Vio *vio, gptr buf, int size) |
| int | vio_write (Vio *vio, const gptr buf, int size) |
| int | vio_blocking (Vio *vio, my_bool onoff, my_bool *old_mode) |
| my_bool | vio_is_blocking (Vio *vio) |
| int | vio_fastsend (Vio *vio) |
| int | vio_keepalive (Vio *vio, my_bool onoff) |
| my_bool | vio_should_retry (Vio *vio) |
| my_bool | vio_was_interrupted (Vio *vio) |
| const char * | vio_description (Vio *vio) |
| enum enum_vio_type | vio_type (Vio *vio) |
| int | vio_errno (Vio *vio) |
| my_socket | vio_fd (Vio *vio) |
| my_bool | vio_peer_addr (Vio *vio, char *buf, uint16 *port) |
| void | vio_in_addr (Vio *vio, struct in_addr *in) |
| my_bool | vio_poll_read (Vio *vio, uint timeout) |
| void | vio_timeout (Vio *vio, uint which, uint timeout) |
| void | vio_end (void) |
| #define HANDLE void * |
Definition at line 59 of file violite.h.
Referenced by CLI_MYSQL_REAL_CONNECT(), close_connections(), NTService::is_super_user(), my_chsize(), NdbThread_Create(), os_awe_enable_lock_pages_in_mem(), os_file_set_eof(), os_mutex_create(), AsyncFile::rmrfReq(), yaSSL::SSL_CTX_load_verify_locations(), and NTService::StartService().
| #define vio_blocking | ( | vio, | |||
| set_blocking_mode, | |||||
| old_mode | ) | (vio)->vioblocking(vio, set_blocking_mode, old_mode) |
Definition at line 145 of file violite.h.
Referenced by my_net_init(), my_real_read(), mysql_manager_connect(), net_clear(), net_real_write(), and vio_init().
| #define VIO_BUFFERED_READ 2 |
| #define vio_close | ( | vio | ) | ((vio)->vioclose)(vio) |
| #define vio_delete | ( | vio | ) | (vio)->viodelete(vio) |
Definition at line 141 of file violite.h.
Referenced by CLI_MYSQL_REAL_CONNECT(), close_connection(), end_server(), handle_connections_sockets(), Listener_thread::handle_new_mysql_connection(), vio_init(), and Mysql_connection_thread::~Mysql_connection_thread().
| #define vio_errno | ( | vio | ) | (vio)->vioerrno(vio) |
Definition at line 142 of file violite.h.
Referenced by my_real_read(), net_real_write(), and vio_init().
| #define vio_fastsend | ( | vio | ) | (vio)->fastsend(vio) |
| #define vio_in_addr | ( | vio, | |||
| in | ) | (vio)->in_addr(vio, in) |
| #define vio_is_blocking | ( | vio | ) | (vio)->is_blocking(vio) |
Definition at line 147 of file violite.h.
Referenced by my_real_read(), net_real_write(), and vio_init().
| #define vio_keepalive | ( | vio, | |||
| set_keep_alive | ) | (vio)->viokeepalive(vio, set_keep_alive) |
Definition at line 149 of file violite.h.
Referenced by check_connection(), CLI_MYSQL_REAL_CONNECT(), Mysql_connection_thread::run(), and vio_init().
| #define VIO_LOCALHOST 1 |
Definition at line 41 of file violite.h.
Referenced by CLI_MYSQL_REAL_CONNECT(), handle_connections_sockets(), and vio_init().
Definition at line 143 of file violite.h.
Referenced by my_real_read(), net_clear(), vio_init(), and vio_read_buff().
| #define VIO_READ_BUFFER_SIZE 16384 |
| #define vio_should_retry | ( | vio | ) | (vio)->should_retry(vio) |
Definition at line 150 of file violite.h.
Referenced by my_real_read(), net_real_write(), and vio_init().
| #define vio_timeout | ( | vio, | |||
| which, | |||||
| seconds | ) | (vio)->timeout(vio, which, seconds) |
Definition at line 155 of file violite.h.
Referenced by my_real_read(), net_real_write(), and vio_init().
| #define vio_was_interrupted | ( | vio | ) | (vio)->was_interrupted(vio) |
| enum enum_vio_type |
| VIO_CLOSED | |
| VIO_TYPE_TCPIP | |
| VIO_TYPE_SOCKET | |
| VIO_TYPE_NAMEDPIPE | |
| VIO_TYPE_SSL | |
| VIO_TYPE_SHARED_MEMORY |
Definition at line 34 of file violite.h.
00035 { 00036 VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, VIO_TYPE_NAMEDPIPE, 00037 VIO_TYPE_SSL, VIO_TYPE_SHARED_MEMORY 00038 };
| enum SSL_type |
Definition at line 159 of file violite.h.
00160 { 00161 SSL_TYPE_NOT_SPECIFIED= -1, 00162 SSL_TYPE_NONE, 00163 SSL_TYPE_ANY, 00164 SSL_TYPE_X509, 00165 SSL_TYPE_SPECIFIED 00166 };
| int vio_close | ( | Vio * | vio | ) |
Definition at line 260 of file viosocket.c.
References closesocket, DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_vio::hPipe, st_vio::sd, socket_errno, st_vio::type, VIO_CLOSED, and VIO_TYPE_NAMEDPIPE.
00261 { 00262 int r=0; 00263 DBUG_ENTER("vio_close"); 00264 #ifdef __WIN__ 00265 if (vio->type == VIO_TYPE_NAMEDPIPE) 00266 { 00267 #if defined(__NT__) && defined(MYSQL_SERVER) 00268 CancelIo(vio->hPipe); 00269 DisconnectNamedPipe(vio->hPipe); 00270 #endif 00271 r=CloseHandle(vio->hPipe); 00272 } 00273 else 00274 #endif /* __WIN__ */ 00275 if (vio->type != VIO_CLOSED) 00276 { 00277 DBUG_ASSERT(vio->sd >= 0); 00278 if (shutdown(vio->sd,2)) 00279 r= -1; 00280 if (closesocket(vio->sd)) 00281 r= -1; 00282 } 00283 if (r) 00284 { 00285 DBUG_PRINT("vio_error", ("close() failed, error: %d",socket_errno)); 00286 /* FIXME: error handling (not critical for MySQL) */ 00287 } 00288 vio->type= VIO_CLOSED; 00289 vio->sd= -1; 00290 DBUG_RETURN(r); 00291 }
| void vio_delete | ( | Vio * | vio | ) |
Definition at line 224 of file vio.c.
References MY_ALLOW_ZERO_PTR, my_free, MYF, st_vio::type, VIO_CLOSED, and st_vio::vioclose.
00225 { 00226 /* It must be safe to delete null pointers. */ 00227 /* This matches the semantics of C++'s delete operator. */ 00228 if (vio) 00229 { 00230 if (vio->type != VIO_CLOSED) 00231 vio->vioclose(vio); 00232 my_free((gptr) vio->read_buffer, MYF(MY_ALLOW_ZERO_PTR)); 00233 my_free((gptr) vio,MYF(0)); 00234 } 00235 }
| const char* vio_description | ( | Vio * | vio | ) |
Definition at line 294 of file viosocket.c.
References st_vio::desc.
Referenced by check_connection(), cli_safe_read(), close_connection(), do_command(), end_server(), and net_clear().
00295 { 00296 return vio->desc; 00297 }
Here is the caller graph for this function:

| void vio_end | ( | void | ) |
Definition at line 243 of file vio.c.
References yaSSL_CleanUp.
Referenced by clean_up(), and mysql_server_end().
00244 { 00245 #ifdef HAVE_YASSL 00246 yaSSL_CleanUp(); 00247 #endif 00248 }
Here is the caller graph for this function:

| int vio_errno | ( | Vio * | vio | ) |
| int vio_fastsend | ( | Vio * | vio | ) |
Definition at line 304 of file viosocket.c.
References st_vio::sd.
Referenced by my_net_init().
00305 { 00306 return vio->sd; 00307 }
Here is the caller graph for this function:

| void vio_in_addr | ( | Vio * | vio, | |
| struct in_addr * | in | |||
| ) |
Definition at line 348 of file viosocket.c.
References bzero, DBUG_ENTER, DBUG_VOID_RETURN, st_vio::localhost, and st_vio::remote.
00349 { 00350 DBUG_ENTER("vio_in_addr"); 00351 if (vio->localhost) 00352 bzero((char*) in, sizeof(*in)); 00353 else 00354 *in=vio->remote.sin_addr; 00355 DBUG_VOID_RETURN; 00356 }
Definition at line 182 of file viosocket.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, and st_vio::fcntl_mode.
00183 { 00184 my_bool r; 00185 DBUG_ENTER("vio_is_blocking"); 00186 r = !(vio->fcntl_mode & O_NONBLOCK); 00187 DBUG_PRINT("exit", ("%d", (int) r)); 00188 DBUG_RETURN(r); 00189 }
Definition at line 224 of file viosocket.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, opt(), st_vio::sd, st_vio::type, and VIO_TYPE_NAMEDPIPE.
00225 { 00226 int r=0; 00227 uint opt = 0; 00228 DBUG_ENTER("vio_keepalive"); 00229 DBUG_PRINT("enter", ("sd: %d set_keep_alive: %d", vio->sd, (int) 00230 set_keep_alive)); 00231 if (vio->type != VIO_TYPE_NAMEDPIPE) 00232 { 00233 if (set_keep_alive) 00234 opt = 1; 00235 r = setsockopt(vio->sd, SOL_SOCKET, SO_KEEPALIVE, (char *) &opt, 00236 sizeof(opt)); 00237 } 00238 DBUG_RETURN(r); 00239 }
Here is the call graph for this function:

| Vio* vio_new | ( | my_socket | sd, | |
| enum enum_vio_type | type, | |||
| uint | flags | |||
| ) |
Definition at line 139 of file vio.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, my_malloc(), MY_WME, MYF, vio_init(), and VIO_TYPE_SOCKET.
Referenced by CLI_MYSQL_REAL_CONNECT(), handle_connections_sockets(), mysql_manager_connect(), and Listener_thread::run().
00140 { 00141 Vio *vio; 00142 DBUG_ENTER("vio_new"); 00143 DBUG_PRINT("enter", ("sd: %d", sd)); 00144 if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME)))) 00145 { 00146 vio_init(vio, type, sd, 0, flags); 00147 sprintf(vio->desc, 00148 (vio->type == VIO_TYPE_SOCKET ? "socket (%d)" : "TCP/IP (%d)"), 00149 vio->sd); 00150 #if !defined(__WIN__) 00151 #if !defined(NO_FCNTL_NONBLOCK) 00152 /* 00153 We call fcntl() to set the flags and then immediately read them back 00154 to make sure that we and the system are in agreement on the state of 00155 things. 00156 00157 An example of why we need to do this is FreeBSD (and apparently some 00158 other BSD-derived systems, like Mac OS X), where the system sometimes 00159 reports that the socket is set for non-blocking when it really will 00160 block. 00161 */ 00162 fcntl(sd, F_SETFL, 0); 00163 vio->fcntl_mode= fcntl(sd, F_GETFL); 00164 #elif defined(HAVE_SYS_IOCTL_H) /* hpux */ 00165 /* Non blocking sockets doesn't work good on HPUX 11.0 */ 00166 (void) ioctl(sd,FIOSNBIO,0); 00167 vio->fcntl_mode &= ~O_NONBLOCK; 00168 #endif 00169 #else /* !defined(__WIN__) */ 00170 { 00171 /* set to blocking mode by default */ 00172 ulong arg=0, r; 00173 r = ioctlsocket(sd,FIONBIO,(void*) &arg); 00174 vio->fcntl_mode &= ~O_NONBLOCK; 00175 } 00176 #endif 00177 } 00178 DBUG_RETURN(vio); 00179 }
Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 310 of file viosocket.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_vio::localhost, my_inet_ntoa(), st_vio::remote, st_vio::sd, socket_errno, and strmov().
00311 { 00312 DBUG_ENTER("vio_peer_addr"); 00313 DBUG_PRINT("enter", ("sd: %d", vio->sd)); 00314 if (vio->localhost) 00315 { 00316 strmov(buf,"127.0.0.1"); 00317 *port= 0; 00318 } 00319 else 00320 { 00321 size_socket addrLen = sizeof(vio->remote); 00322 if (getpeername(vio->sd, (struct sockaddr *) (&vio->remote), 00323 &addrLen) != 0) 00324 { 00325 DBUG_PRINT("exit", ("getpeername gave error: %d", socket_errno)); 00326 DBUG_RETURN(1); 00327 } 00328 my_inet_ntoa(vio->remote.sin_addr,buf); 00329 *port= ntohs(vio->remote.sin_port); 00330 } 00331 DBUG_PRINT("exit", ("addr: %s", buf)); 00332 DBUG_RETURN(0); 00333 }
Here is the call graph for this function:

Definition at line 361 of file viosocket.c.
References DBUG_ENTER, DBUG_RETURN, and st_vio::sd.
Referenced by CLI_MYSQL_REAL_CONNECT().
00362 { 00363 #ifndef HAVE_POLL 00364 return 0; 00365 #else 00366 struct pollfd fds; 00367 int res; 00368 DBUG_ENTER("vio_poll"); 00369 fds.fd=vio->sd; 00370 fds.events=POLLIN; 00371 fds.revents=0; 00372 if ((res=poll(&fds,1,(int) timeout*1000)) <= 0) 00373 { 00374 DBUG_RETURN(res < 0 ? 0 : 1); /* Don't return 1 on errors */ 00375 } 00376 DBUG_RETURN(fds.revents & POLLIN ? 0 : 1); 00377 #endif 00378 }
Here is the caller graph for this function:

Definition at line 32 of file viosocket.c.
References DBUG_ASSERT, DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, errno, st_vio::read_end, st_vio::read_pos, and st_vio::sd.
00033 { 00034 int r; 00035 DBUG_ENTER("vio_read"); 00036 DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, 00037 size)); 00038 00039 /* Ensure nobody uses vio_read_buff and vio_read simultaneously */ 00040 DBUG_ASSERT(vio->read_end == vio->read_pos); 00041 #ifdef __WIN__ 00042 r = recv(vio->sd, buf, size,0); 00043 #else 00044 errno=0; /* For linux */ 00045 r = read(vio->sd, buf, size); 00046 #endif /* __WIN__ */ 00047 #ifndef DBUG_OFF 00048 if (r < 0) 00049 { 00050 DBUG_PRINT("vio_error", ("Got error %d during read",errno)); 00051 } 00052 #endif /* DBUG_OFF */ 00053 DBUG_PRINT("exit", ("%d", r)); 00054 DBUG_RETURN(r); 00055 }
Definition at line 63 of file viosocket.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, memcpy, min, st_vio::read_buffer, st_vio::read_end, st_vio::read_pos, st_vio::sd, vio_read, VIO_READ_BUFFER_SIZE, and VIO_UNBUFFERED_READ_MIN_SIZE.
Referenced by vio_init().
00064 { 00065 int rc; 00066 #define VIO_UNBUFFERED_READ_MIN_SIZE 2048 00067 DBUG_ENTER("vio_read_buff"); 00068 DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, 00069 size)); 00070 00071 if (vio->read_pos < vio->read_end) 00072 { 00073 rc= min(vio->read_end - vio->read_pos, size); 00074 memcpy(buf, vio->read_pos, rc); 00075 vio->read_pos+= rc; 00076 /* 00077 Do not try to read from the socket now even if rc < size: 00078 vio_read can return -1 due to an error or non-blocking mode, and 00079 the safest way to handle it is to move to a separate branch. 00080 */ 00081 } 00082 else if (size < VIO_UNBUFFERED_READ_MIN_SIZE) 00083 { 00084 rc= vio_read(vio, vio->read_buffer, VIO_READ_BUFFER_SIZE); 00085 if (rc > 0) 00086 { 00087 if (rc > size) 00088 { 00089 vio->read_pos= vio->read_buffer + size; 00090 vio->read_end= vio->read_buffer + rc; 00091 rc= size; 00092 } 00093 memcpy(buf, vio->read_buffer, rc); 00094 } 00095 } 00096 else 00097 rc= vio_read(vio, buf, size); 00098 DBUG_RETURN(rc); 00099 #undef VIO_UNBUFFERED_READ_MIN_SIZE 00100 }
Here is the caller graph for this function:

| void vio_reset | ( | Vio * | vio, | |
| enum enum_vio_type | type, | |||
| my_socket | sd, | |||
| HANDLE | hPipe, | |||
| uint | flags | |||
| ) |
Definition at line 129 of file vio.c.
References MY_ALLOW_ZERO_PTR, my_free, MYF, st_vio::read_buffer, and vio_init().
00131 { 00132 my_free(vio->read_buffer, MYF(MY_ALLOW_ZERO_PTR)); 00133 vio_init(vio, type, sd, hPipe, flags); 00134 }
Here is the call graph for this function:

| enum enum_vio_type vio_type | ( | Vio * | vio | ) |
Definition at line 299 of file viosocket.c.
References st_vio::type.
Referenced by handle_one_connection().
00300 { 00301 return vio->type; 00302 }
Here is the caller graph for this function:

Definition at line 103 of file viosocket.c.
References DBUG_ENTER, DBUG_PRINT, DBUG_RETURN, st_vio::sd, and socket_errno.
00104 { 00105 int r; 00106 DBUG_ENTER("vio_write"); 00107 DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, 00108 size)); 00109 #ifdef __WIN__ 00110 r = send(vio->sd, buf, size,0); 00111 #else 00112 r = write(vio->sd, buf, size); 00113 #endif /* __WIN__ */ 00114 #ifndef DBUG_OFF 00115 if (r < 0) 00116 { 00117 DBUG_PRINT("vio_error", ("Got error on write: %d",socket_errno)); 00118 } 00119 #endif /* DBUG_OFF */ 00120 DBUG_PRINT("exit", ("%d", r)); 00121 DBUG_RETURN(r); 00122 }
1.4.7

