Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

PHP mysqlnd svn commit: r959 - trunk/mysqlnd

From: <ahristov(at)mysql.com>
Date: Wed Aug 29 2007 - 11:19:19 EDT


Author: ahristov
Date: 2007-08-29 17:19:19 +0200 (Wed, 29 Aug 2007) New Revision: 959

Modified:

   trunk/mysqlnd/mysqlnd_debug.c
Log:
Change time format
Fix a leak

Modified: trunk/mysqlnd/mysqlnd_debug.c


  • trunk/mysqlnd/mysqlnd_debug.c 2007-08-29 14:48:28 UTC (rev 958) +++ trunk/mysqlnd/mysqlnd_debug.c 2007-08-29 15:19:19 UTC (rev 959) @@ -74,7 +74,6 @@ int i; char * message_line; size_t message_line_len; - struct timeval tv; unsigned int flags = self->flags; char pid_buffer[10], time_buffer[30], file_buffer[200], line_buffer[6], level_buffer[4]; @@ -101,9 +100,34 @@ snprintf(pid_buffer, sizeof(pid_buffer), "[%5u]", self->pid);
    }
    if (flags & MYSQLND_DEBUG_DUMP_TIME) { - gettimeofday(&tv, NULL); - snprintf(time_buffer, sizeof(time_buffer), "[%lu.%6lu]", tv.tv_sec, (long int)tv.tv_usec); + /* The following from FF's DBUG library, which is in the public domain */ +#if defined(PHP_WIN32) + /* FIXME This doesn't give microseconds as in Unix case, and the resolution is + in system ticks, 10 ms intervals. See my_getsystime.c for high res */ + SYSTEMTIME loc_t; + GetLocalTime(&loc_t); + snprintf(time_buffer, sizeof(time_buffer), + /* "%04d-%02d-%02d " */ + "%02d:%02d:%02d.%06d ", + /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/, + loc_t.wHour, loc_t.wMinute, loc_t.wSecond, loc_t.wMilliseconds); +#else + struct timeval tv; + struct tm *tm_p; + if (gettimeofday(&tv, NULL) != -1) { + if ((tm_p= localtime((const time_t *)&tv.tv_sec))) { + snprintf(time_buffer, sizeof(time_buffer), + /* "%04d-%02d-%02d " */ + "%02d:%02d:%02d.%06d ", + /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/ + tm_p->tm_hour, tm_p->tm_min, tm_p->tm_sec, + (int) (tv.tv_usec)); + } + } +#endif +
    }
    + if (flags & MYSQLND_DEBUG_DUMP_FILE) { snprintf(file_buffer, sizeof(file_buffer), "[%20s]", file);
    }
    @@ -146,7 +170,6 @@ enum_func_status ret; char * message_line, *buffer; size_t message_line_len; - struct timeval tv; va_list args; unsigned int flags = self->flags; char pid_buffer[10], time_buffer[30], file_buffer[200], @@ -174,8 +197,32 @@ snprintf(pid_buffer, sizeof(pid_buffer), "[%5u]", self->pid);
    }
    if (flags & MYSQLND_DEBUG_DUMP_TIME) { - gettimeofday(&tv, NULL); - snprintf(time_buffer, sizeof(time_buffer), "[%lu.%6lu]", tv.tv_sec, (long int)tv.tv_usec); + /* The following from FF's DBUG library, which is in the public domain */ +#if defined(PHP_WIN32) + /* FIXME This doesn't give microseconds as in Unix case, and the resolution is + in system ticks, 10 ms intervals. See my_getsystime.c for high res */ + SYSTEMTIME loc_t; + GetLocalTime(&loc_t); + snprintf(time_buffer, sizeof(time_buffer), + /* "%04d-%02d-%02d " */ + "%02d:%02d:%02d.%06d ", + /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/, + loc_t.wHour, loc_t.wMinute, loc_t.wSecond, loc_t.wMilliseconds); +#else + struct timeval tv; + struct tm *tm_p; + if (gettimeofday(&tv, NULL) != -1) { + if ((tm_p= localtime((const time_t *)&tv.tv_sec))) { + snprintf(time_buffer, sizeof(time_buffer), + /* "%04d-%02d-%02d " */ + "%02d:%02d:%02d.%06d ", + /*tm_p->tm_year + 1900, tm_p->tm_mon + 1, tm_p->tm_mday,*/ + tm_p->tm_hour, tm_p->tm_min, tm_p->tm_sec, + (int) (tv.tv_usec)); + } + } +#endif +
    }
    if (flags & MYSQLND_DEBUG_DUMP_FILE) { snprintf(file_buffer, sizeof(file_buffer), "[%20s]", file); @@ -257,8 +304,9 @@ static enum_func_status MYSQLND_METHOD(mysqlnd_debug, free)(MYSQLND_DEBUG * self) { - if (self->file_name != mysqlnd_debug_default_trace_file) { + if (self->file_name && self->file_name != mysqlnd_debug_default_trace_file) { efree(self->file_name); + self->file_name = NULL;
    }
    zend_stack_destroy(&self->call_stack); efree(self); @@ -282,6 +330,13 @@ size_t mode_len = strlen(mode), i; enum mysqlnd_debug_parser_state state = PARSER_WAIT_MODIFIER;
+	self->flags = 0;
+	self->nest_level_limit = (unsigned int) ~0;
+	if (self->file_name && self->file_name != mysqlnd_debug_default_trace_file) {
+		efree(self->file_name);
+		self->file_name = (char *) mysqlnd_debug_default_trace_file;
+	}
+
 	for (i = 0; i < mode_len; i++) {
 		switch (mode[i]) {
 			case 'A':
-- 
MySQL Code Commits Mailing List
For list archives: 
http://lists.mysql.com/commits
To unsubscribe:    
http://lists.mysql.com/commits?unsub=lists@pantek.com
Received on Wed Aug 29 11:20:37 2007

This archive was generated by hypermail 2.1.8 : Sun Oct 07 2007 - 08:55:36 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library