New version for gw_mysql_close()

This commit is contained in:
Massimiliano Pinto
2013-06-10 15:11:03 +02:00
parent 3413f29e5a
commit ac08cb4368

View File

@ -34,7 +34,7 @@ Massimiliano Pinto
#include "session.h"
#define MYSQL_CONN_DEBUG
#undef MYSQL_CONN_DEBUG
//#undef MYSQL_CONN_DEBUG
int mysql_send_ok(int fd, int packet_number, int in_affected_rows, const char* mysql_message) {
int n = 0;
@ -737,15 +737,14 @@ int gw_mysql_connect(char *host, int port, char *dbname, char *user, char *passw
// free data scructure
//////////////////////////////////////
void gw_mysql_close(MySQLProtocol **ptr) {
int rv;
uint8_t packet_buffer[5];
MySQLProtocol *conn = *ptr;
if (conn == NULL)
if (*ptr == NULL)
return;
if (conn->fd > 0) {
fprintf(stderr, "Closing MySQL connection %i, [%s]\n", conn->fd, conn->scramble);
if (conn->fd > 0) {
//write COM_QUIT
//write
@ -755,15 +754,15 @@ void gw_mysql_close(MySQLProtocol **ptr) {
close(conn->fd);
} else {
#ifdef MYSQL_CONN_DEBUG
fprintf(stderr, "mysqlgw_mysql_close() called, no socket\n");
fprintf(stderr, "mysqlgw_mysql_close() called, no socket %i\n", conn->fd);
#endif
}
if (conn != NULL) {
free(conn);
free(*ptr);
*ptr = NULL;
#ifdef MYSQL_CONN_DEBUG
fprintf(stderr, "mysqlgw_mysql_close() free(conn)\n");
#endif
}
}