Esempio n. 1
0
/**
 * handle the events of a idling server connection in the pool 
 *
 * make sure we know about connection close from the server side
 * - wait_timeout
 */
static void network_mysqld_con_idle_handle(int event_fd, short events, void *user_data) {
	network_connection_pool_entry *pool_entry = user_data;
	network_connection_pool *pool             = pool_entry->pool;

	if (events == EV_READ) {
		int b = -1;

		/**
		 * @todo we have to handle the case that the server really sent us something
		 *        up to now we just ignore it
		 */
		if (ioctlsocket(event_fd, FIONREAD, &b)) {
			g_critical("ioctl(%d, FIONREAD, ...) failed: %s", event_fd, g_strerror(errno));
		} else if (b != 0) {
			g_critical("ioctl(%d, FIONREAD, ...) said there is something to read, oops: %d", event_fd, b);
		} else {
			/* the server decided to close the connection (wait_timeout, crash, ... )
			 *
			 * remove us from the connection pool and close the connection */
		

			network_connection_pool_remove(pool, pool_entry); // not in lua, so lock like lua_lock
		}
	}
}
/**
 * handle the events of a idling server connection in the pool
 *
 * make sure we know about connection close from the server side
 * - wait_timeout
 */
static void network_mysqld_con_idle_handle(int event_fd, short events,
			void *user_data) {
	network_connection_pool_entry *pool_entry = user_data;
	network_connection_pool *pool = pool_entry->pool;

	if (events == EV_READ) {
		int b = -1;
		/**
		 * @todo we have to handle the case that the server really sent use
		 * something up to now we just ignore it
		 */
		if (ioctlsocket(event_fd, FIONREAD, &b))
			g_critical("ioctl(%d, FIONREAD, ...) failed: %s", event_fd,
						g_strerror(errno));
		else if (b != 0)
			g_critical("ioctl(%d, FIONREAD, ...) said there is something to "
						"read, oops: %d", event_fd, b);
		else
			network_connection_pool_remove(pool, pool_entry);
	}
}