diff options
Diffstat (limited to 'sql-common/client.c')
-rw-r--r-- | sql-common/client.c | 327 |
1 files changed, 12 insertions, 315 deletions
diff --git a/sql-common/client.c b/sql-common/client.c index 6bf29f056a2..09f7abcce90 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -127,10 +127,6 @@ char *mysql_unix_port= 0; const char *unknown_sqlstate= "HY000"; const char *not_error_sqlstate= "00000"; const char *cant_connect_sqlstate= "08001"; -#ifdef HAVE_SMEM -char *shared_memory_base_name= 0; -const char *def_shared_memory_base_name= default_shared_memory_base_name; -#endif static void mysql_close_free_options(MYSQL *mysql); static void mysql_close_free(MYSQL *mysql); @@ -326,248 +322,6 @@ HANDLE create_named_pipe(MYSQL *mysql, uint connect_timeout, char **arg_host, #endif -/* - Create new shared memory connection, return handler of connection - - SYNOPSIS - create_shared_memory() - mysql Pointer of mysql structure - net Pointer of net structure - connect_timeout Timeout of connection -*/ - -#ifdef HAVE_SMEM -HANDLE create_shared_memory(MYSQL *mysql,NET *net, uint connect_timeout) -{ - ulong smem_buffer_length = shared_memory_buffer_length + 4; - /* - event_connect_request is event object for start connection actions - event_connect_answer is event object for confirm, that server put data - handle_connect_file_map is file-mapping object, use for create shared - memory - handle_connect_map is pointer on shared memory - handle_map is pointer on shared memory for client - event_server_wrote, - event_server_read, - event_client_wrote, - event_client_read are events for transfer data between server and client - handle_file_map is file-mapping object, use for create shared memory - */ - HANDLE event_connect_request = NULL; - HANDLE event_connect_answer = NULL; - HANDLE handle_connect_file_map = NULL; - char *handle_connect_map = NULL; - - char *handle_map = NULL; - HANDLE event_server_wrote = NULL; - HANDLE event_server_read = NULL; - HANDLE event_client_wrote = NULL; - HANDLE event_client_read = NULL; - HANDLE event_conn_closed = NULL; - HANDLE handle_file_map = NULL; - ulong connect_number; - char connect_number_char[22], *p; - char *tmp= NULL; - char *suffix_pos; - DWORD error_allow = 0; - DWORD error_code = 0; - DWORD event_access_rights= SYNCHRONIZE | EVENT_MODIFY_STATE; - char *shared_memory_base_name = mysql->options.shared_memory_base_name; - static const char *name_prefixes[] = {"","Global\\"}; - const char *prefix; - uint i; - - /* - If this is NULL, somebody freed the MYSQL* options. mysql_close() - is a good candidate. We don't just silently (re)set it to - def_shared_memory_base_name as that would create really confusing/buggy - behavior if the user passed in a different name on the command-line or - in a my.cnf. - */ - DBUG_ASSERT(shared_memory_base_name != NULL); - - /* - get enough space base-name + '_' + longest suffix we might ever send - */ - if (!(tmp= (char *)my_malloc(strlen(shared_memory_base_name) + 32L, MYF(MY_FAE)))) - goto err; - - /* - The name of event and file-mapping events create agree next rule: - shared_memory_base_name+unique_part - Where: - shared_memory_base_name is unique value for each server - unique_part is uniquel value for each object (events and file-mapping) - */ - for (i = 0; i< array_elements(name_prefixes); i++) - { - prefix= name_prefixes[i]; - suffix_pos = strxmov(tmp, prefix , shared_memory_base_name, "_", NullS); - strmov(suffix_pos, "CONNECT_REQUEST"); - event_connect_request= OpenEvent(event_access_rights, FALSE, tmp); - if (event_connect_request) - { - break; - } - } - if (!event_connect_request) - { - error_allow = CR_SHARED_MEMORY_CONNECT_REQUEST_ERROR; - goto err; - } - strmov(suffix_pos, "CONNECT_ANSWER"); - if (!(event_connect_answer= OpenEvent(event_access_rights,FALSE,tmp))) - { - error_allow = CR_SHARED_MEMORY_CONNECT_ANSWER_ERROR; - goto err; - } - strmov(suffix_pos, "CONNECT_DATA"); - if (!(handle_connect_file_map= OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp))) - { - error_allow = CR_SHARED_MEMORY_CONNECT_FILE_MAP_ERROR; - goto err; - } - if (!(handle_connect_map= MapViewOfFile(handle_connect_file_map, - FILE_MAP_WRITE,0,0,sizeof(DWORD)))) - { - error_allow = CR_SHARED_MEMORY_CONNECT_MAP_ERROR; - goto err; - } - - /* Send to server request of connection */ - if (!SetEvent(event_connect_request)) - { - error_allow = CR_SHARED_MEMORY_CONNECT_SET_ERROR; - goto err; - } - - /* Wait of answer from server */ - if (WaitForSingleObject(event_connect_answer,connect_timeout*1000) != - WAIT_OBJECT_0) - { - error_allow = CR_SHARED_MEMORY_CONNECT_ABANDONED_ERROR; - goto err; - } - - /* Get number of connection */ - connect_number = uint4korr(handle_connect_map);/*WAX2*/ - p= int10_to_str(connect_number, connect_number_char, 10); - - /* - The name of event and file-mapping events create agree next rule: - shared_memory_base_name+unique_part+number_of_connection - - Where: - shared_memory_base_name is uniquel value for each server - unique_part is uniquel value for each object (events and file-mapping) - number_of_connection is number of connection between server and client - */ - suffix_pos = strxmov(tmp, prefix , shared_memory_base_name, "_", connect_number_char, - "_", NullS); - strmov(suffix_pos, "DATA"); - if ((handle_file_map = OpenFileMapping(FILE_MAP_WRITE,FALSE,tmp)) == NULL) - { - error_allow = CR_SHARED_MEMORY_FILE_MAP_ERROR; - goto err2; - } - if ((handle_map = MapViewOfFile(handle_file_map,FILE_MAP_WRITE,0,0, - smem_buffer_length)) == NULL) - { - error_allow = CR_SHARED_MEMORY_MAP_ERROR; - goto err2; - } - - strmov(suffix_pos, "SERVER_WROTE"); - if ((event_server_wrote = OpenEvent(event_access_rights,FALSE,tmp)) == NULL) - { - error_allow = CR_SHARED_MEMORY_EVENT_ERROR; - goto err2; - } - - strmov(suffix_pos, "SERVER_READ"); - if ((event_server_read = OpenEvent(event_access_rights,FALSE,tmp)) == NULL) - { - error_allow = CR_SHARED_MEMORY_EVENT_ERROR; - goto err2; - } - - strmov(suffix_pos, "CLIENT_WROTE"); - if ((event_client_wrote = OpenEvent(event_access_rights,FALSE,tmp)) == NULL) - { - error_allow = CR_SHARED_MEMORY_EVENT_ERROR; - goto err2; - } - - strmov(suffix_pos, "CLIENT_READ"); - if ((event_client_read = OpenEvent(event_access_rights,FALSE,tmp)) == NULL) - { - error_allow = CR_SHARED_MEMORY_EVENT_ERROR; - goto err2; - } - - strmov(suffix_pos, "CONNECTION_CLOSED"); - if ((event_conn_closed = OpenEvent(event_access_rights,FALSE,tmp)) == NULL) - { - error_allow = CR_SHARED_MEMORY_EVENT_ERROR; - goto err2; - } - /* - Set event that server should send data - */ - SetEvent(event_server_read); - -err2: - if (error_allow == 0) - { - net->vio= vio_new_win32shared_memory(handle_file_map,handle_map, - event_server_wrote, - event_server_read,event_client_wrote, - event_client_read,event_conn_closed); - } - else - { - error_code = GetLastError(); - if (event_server_read) - CloseHandle(event_server_read); - if (event_server_wrote) - CloseHandle(event_server_wrote); - if (event_client_read) - CloseHandle(event_client_read); - if (event_client_wrote) - CloseHandle(event_client_wrote); - if (event_conn_closed) - CloseHandle(event_conn_closed); - if (handle_map) - UnmapViewOfFile(handle_map); - if (handle_file_map) - CloseHandle(handle_file_map); - } -err: - my_free(tmp); - if (error_allow) - error_code = GetLastError(); - if (event_connect_request) - CloseHandle(event_connect_request); - if (event_connect_answer) - CloseHandle(event_connect_answer); - if (handle_connect_map) - UnmapViewOfFile(handle_connect_map); - if (handle_connect_file_map) - CloseHandle(handle_connect_file_map); - if (error_allow) - { - if (error_allow == CR_SHARED_MEMORY_EVENT_ERROR) - set_mysql_extended_error(mysql, error_allow, unknown_sqlstate, - ER(error_allow), suffix_pos, error_code); - else - set_mysql_extended_error(mysql, error_allow, unknown_sqlstate, - ER(error_allow), error_code); - return(INVALID_HANDLE_VALUE); - } - return(handle_map); -} -#endif - /** Read a packet from server. Give error message if socket was down or packet is an error message @@ -987,7 +741,7 @@ static const char *default_options[]= "ssl-key" ,"ssl-cert" ,"ssl-ca" ,"ssl-capath", "character-sets-dir", "default-character-set", "interactive-timeout", "connect-timeout", "local-infile", "disable-local-infile", - "ssl-cipher", "max-allowed-packet", "protocol", "shared-memory-base-name", + "ssl-cipher", "max-allowed-packet", "protocol", "multi-results", "multi-statements", "multi-queries", "secure-auth", "report-data-truncation", "plugin-dir", "default-auth", "bind-address", "ssl-crl", "ssl-crlpath", @@ -1000,7 +754,7 @@ enum option_id { OPT_ssl_key, OPT_ssl_cert, OPT_ssl_ca, OPT_ssl_capath, OPT_character_sets_dir, OPT_default_character_set, OPT_interactive_timeout, OPT_connect_timeout, OPT_local_infile, OPT_disable_local_infile, - OPT_ssl_cipher, OPT_max_allowed_packet, OPT_protocol, OPT_shared_memory_base_name, + OPT_ssl_cipher, OPT_max_allowed_packet, OPT_protocol, OPT_multi_results, OPT_multi_statements, OPT_multi_queries, OPT_secure_auth, OPT_report_data_truncation, OPT_plugin_dir, OPT_default_auth, OPT_bind_address, OPT_ssl_crl, OPT_ssl_crlpath, @@ -1241,13 +995,6 @@ void mysql_read_default_options(struct st_mysql_options *options, options->protocol= UINT_MAX32; } break; - case OPT_shared_memory_base_name: -#ifdef HAVE_SMEM - if (options->shared_memory_base_name != def_shared_memory_base_name) - my_free(options->shared_memory_base_name); - options->shared_memory_base_name=my_strdup(opt_arg,MYF(MY_WME)); -#endif - break; case OPT_multi_results: options->client_flag|= CLIENT_MULTI_RESULTS; break; @@ -1654,10 +1401,6 @@ mysql_init(MYSQL *mysql) ? WAIT_FOR_QUERY : ALWAYS_ACCEPT; #endif -#ifdef HAVE_SMEM - mysql->options.shared_memory_base_name= (char*) def_shared_memory_base_name; -#endif - mysql->options.methods_to_use= MYSQL_OPT_GUESS_CONNECTION; mysql->options.report_data_truncation= TRUE; /* default */ @@ -1847,9 +1590,15 @@ static int ssl_verify_server_cert(Vio *vio, const char* server_hostname, const c #ifdef HAVE_X509_check_host ret_validation= - (X509_check_host(server_cert, server_hostname, - strlen(server_hostname), 0, 0) != 1) && - (X509_check_ip_asc(server_cert, server_hostname, 0) != 1); + X509_check_host(server_cert, server_hostname, + strlen(server_hostname), 0, 0) != 1; +#ifndef HAVE_WOLFSSL + if (ret_validation) + { + ret_validation= + X509_check_ip_asc(server_cert, server_hostname, 0) != 1; + } +#endif #else subject= X509_get_subject_name(server_cert); cn_loc= X509_NAME_get_index_by_NID(subject, NID_commonName, -1); @@ -2624,12 +2373,6 @@ void mpvio_info(Vio *vio, MYSQL_PLUGIN_VIO_INFO *info) info->protocol= MYSQL_VIO_PIPE; info->handle= vio->hPipe; return; - case VIO_TYPE_SHARED_MEMORY: - info->protocol= MYSQL_VIO_MEMORY; -#ifdef HAVE_SMEM - info->handle= vio->handle_file_map; /* or what ? */ -#endif - return; #endif default: DBUG_ASSERT(0); } @@ -2964,42 +2707,7 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user, /* Part 0: Grab a socket and connect it to the server */ -#if defined(HAVE_SMEM) - if ((!mysql->options.protocol || - mysql->options.protocol == MYSQL_PROTOCOL_MEMORY) && - (!host || !strcmp(host,LOCAL_HOST)) && - mysql->options.shared_memory_base_name) - { - DBUG_PRINT("info", ("Using shared memory")); - if ((create_shared_memory(mysql,net, mysql->options.connect_timeout)) == - INVALID_HANDLE_VALUE) - { - DBUG_PRINT("error", - ("host: '%s' socket: '%s' shared memory: %s have_tcpip: %d", - host ? host : "<null>", - unix_socket ? unix_socket : "<null>", - mysql->options.shared_memory_base_name, - (int) have_tcpip)); - if (mysql->options.protocol == MYSQL_PROTOCOL_MEMORY) - goto error; - /* - Try also with PIPE or TCP/IP. Clear the error from - create_shared_memory(). - */ - - net_clear_error(net); - } - else - { - mysql->options.protocol=MYSQL_PROTOCOL_MEMORY; - unix_socket = 0; - host=mysql->options.shared_memory_base_name; - my_snprintf(host_info=buff, sizeof(buff)-1, - ER(CR_SHARED_MEMORY_CONNECTION), host); - } - } -#endif /* HAVE_SMEM */ #if defined(HAVE_SYS_UN_H) if (!net->vio && (!mysql->options.protocol || @@ -3615,10 +3323,6 @@ static void mysql_close_free_options(MYSQL *mysql) #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) mysql_ssl_free(mysql); #endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY */ -#ifdef HAVE_SMEM - if (mysql->options.shared_memory_base_name != def_shared_memory_base_name) - my_free(mysql->options.shared_memory_base_name); -#endif /* HAVE_SMEM */ if (mysql->options.extension) { struct mysql_async_context *ctxt= mysql->options.extension->async_context; @@ -4117,13 +3821,6 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg) case MYSQL_OPT_PROTOCOL: mysql->options.protocol= *(uint*) arg; break; - case MYSQL_SHARED_MEMORY_BASE_NAME: -#ifdef HAVE_SMEM - if (mysql->options.shared_memory_base_name != def_shared_memory_base_name) - my_free(mysql->options.shared_memory_base_name); - mysql->options.shared_memory_base_name=my_strdup(arg,MYF(MY_WME)); -#endif - break; case MYSQL_OPT_USE_REMOTE_CONNECTION: case MYSQL_OPT_USE_EMBEDDED_CONNECTION: case MYSQL_OPT_GUESS_CONNECTION: @@ -4261,8 +3958,8 @@ mysql_options(MYSQL *mysql,enum mysql_option option, const void *arg) } } break; + case MYSQL_SHARED_MEMORY_BASE_NAME: default: - break; DBUG_RETURN(1); } DBUG_RETURN(0); |