Merge
This commit is contained in:
		| @ -95,6 +95,7 @@ DCB	*rval; | |||||||
| 	rval->data = NULL; | 	rval->data = NULL; | ||||||
| 	rval->protocol = NULL; | 	rval->protocol = NULL; | ||||||
| 	rval->session = NULL; | 	rval->session = NULL; | ||||||
|  |         simple_mutex_init(&rval->mutex, "dcb mutex"); | ||||||
| 	memset(&rval->stats, 0, sizeof(DCBSTATS));	// Zero the statistics | 	memset(&rval->stats, 0, sizeof(DCBSTATS));	// Zero the statistics | ||||||
| 	bitmask_init(&rval->memdata.bitmask); | 	bitmask_init(&rval->memdata.bitmask); | ||||||
| 	rval->memdata.next = NULL; | 	rval->memdata.next = NULL; | ||||||
| @ -342,6 +343,7 @@ GWPROTOCOL	*funcs; | |||||||
| int | int | ||||||
| dcb_read(DCB *dcb, GWBUF **head) | dcb_read(DCB *dcb, GWBUF **head) | ||||||
| { | { | ||||||
|  | <<<<<<< TREE | ||||||
| GWBUF 	  *buffer = NULL; | GWBUF 	  *buffer = NULL; | ||||||
| int 	  b, n = 0; | int 	  b, n = 0; | ||||||
| int       rc = 0; | int       rc = 0; | ||||||
| @ -364,6 +366,10 @@ int       eno = 0; | |||||||
|                 return -1; |                 return -1; | ||||||
|         } |         } | ||||||
|          |          | ||||||
|  | ======= | ||||||
|  | GWBUF 	  *buffer = NULL; | ||||||
|  | int 	  b, n = 0; | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
| 	while (b > 0) | 	while (b > 0) | ||||||
| 	{ | 	{ | ||||||
| 		int bufsize = b < MAX_BUFFER_SIZE ? b : MAX_BUFFER_SIZE; | 		int bufsize = b < MAX_BUFFER_SIZE ? b : MAX_BUFFER_SIZE; | ||||||
| @ -472,12 +478,28 @@ int	w, saved_errno = 0; | |||||||
| 			saved_errno = errno; | 			saved_errno = errno; | ||||||
| 			if (w < 0) | 			if (w < 0) | ||||||
| 			{ | 			{ | ||||||
|  | <<<<<<< TREE | ||||||
|                             skygw_log_write( |                             skygw_log_write( | ||||||
|                                     LOGFILE_ERROR, |                                     LOGFILE_ERROR, | ||||||
|                                     "%lu [dcb_write] Write to fd %d failed, errno %d", |                                     "%lu [dcb_write] Write to fd %d failed, errno %d", | ||||||
|                                     pthread_self(), |                                     pthread_self(), | ||||||
|                                     dcb->fd, |                                     dcb->fd, | ||||||
|                                     saved_errno); |                                     saved_errno); | ||||||
|  | ======= | ||||||
|  |                             skygw_log_write( | ||||||
|  |                                     LOGFILE_ERROR, | ||||||
|  |                                     "%lu [dcb_write] Write to fd %d failed, errno %d", | ||||||
|  |                                     pthread_self(), | ||||||
|  |                                     dcb->fd, | ||||||
|  |                                     saved_errno); | ||||||
|  |                             skygw_log_write( | ||||||
|  |                                     LOGFILE_TRACE, | ||||||
|  |                                     "%lu [dcb_write] Write to fd %d failed, errno %d", | ||||||
|  |                                     pthread_self(), | ||||||
|  |                                     dcb->fd, | ||||||
|  |                                     saved_errno); | ||||||
|  |  | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
| 				break; | 				break; | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| @ -547,6 +569,7 @@ int saved_errno = 0; | |||||||
| 			saved_errno = errno; | 			saved_errno = errno; | ||||||
| 			if (w < 0) | 			if (w < 0) | ||||||
| 			{ | 			{ | ||||||
|  | <<<<<<< TREE | ||||||
|                             skygw_log_write( |                             skygw_log_write( | ||||||
|                                     LOGFILE_ERROR, |                                     LOGFILE_ERROR, | ||||||
|                                     "%lu [dcb_drain_writeq] Write to fd %d failed, " |                                     "%lu [dcb_drain_writeq] Write to fd %d failed, " | ||||||
| @ -555,6 +578,24 @@ int saved_errno = 0; | |||||||
|                                     dcb->fd, |                                     dcb->fd, | ||||||
|                                     saved_errno); |                                     saved_errno); | ||||||
|                             break; |                             break; | ||||||
|  | ======= | ||||||
|  |                             skygw_log_write( | ||||||
|  |                                     LOGFILE_ERROR, | ||||||
|  |                                     "%lu [dcb_drain_writeq] Write to fd %d failed, " | ||||||
|  |                                     "errno %d", | ||||||
|  |                                     pthread_self(), | ||||||
|  |                                     dcb->fd, | ||||||
|  |                                     saved_errno); | ||||||
|  |                             skygw_log_write( | ||||||
|  |                                     LOGFILE_TRACE, | ||||||
|  |                                     "%lu [dcb_drain_writeq] Write to df %d failed, " | ||||||
|  |                                     "errno %d", | ||||||
|  |                                     pthread_self(), | ||||||
|  |                                     dcb->fd, | ||||||
|  |                                     saved_errno); | ||||||
|  |                              | ||||||
|  |                             break; | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			/* | 			/* | ||||||
|  | |||||||
| @ -195,13 +195,28 @@ bool                    no_op = FALSE; | |||||||
| 			{ | 			{ | ||||||
| 				DCB 		*dcb = (DCB *)events[i].data.ptr; | 				DCB 		*dcb = (DCB *)events[i].data.ptr; | ||||||
| 				__uint32_t	ev = events[i].events; | 				__uint32_t	ev = events[i].events; | ||||||
|  | <<<<<<< TREE | ||||||
|                                  |                                  | ||||||
|                                 skygw_log_write( |                                 skygw_log_write( | ||||||
|                                         LOGFILE_TRACE, |                                         LOGFILE_TRACE, | ||||||
|                                         "%lu [poll_waitevents] event %d", |                                         "%lu [poll_waitevents] event %d", | ||||||
|                                         pthread_self(), |                                         pthread_self(), | ||||||
|                                         ev); |                                         ev); | ||||||
|  | ======= | ||||||
|  |                                 simple_mutex_t* mutex = &dcb->mutex; | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
|  | <<<<<<< TREE | ||||||
|  | ======= | ||||||
|  |                                 simple_mutex_lock(mutex, TRUE); | ||||||
|  |                                  | ||||||
|  |                                 skygw_log_write( | ||||||
|  |                                         LOGFILE_TRACE, | ||||||
|  |                                         "%lu [poll_waitevents] event %d", | ||||||
|  |                                         pthread_self(), | ||||||
|  |                                         ev); | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
| 				if (DCB_ISZOMBIE(dcb)) | 				if (DCB_ISZOMBIE(dcb)) | ||||||
|  | <<<<<<< TREE | ||||||
|                                 { |                                 { | ||||||
|                                         skygw_log_write( |                                         skygw_log_write( | ||||||
|                                                 LOGFILE_TRACE, |                                                 LOGFILE_TRACE, | ||||||
| @ -209,12 +224,27 @@ bool                    no_op = FALSE; | |||||||
|                                                 pthread_self()); |                                                 pthread_self()); | ||||||
|                                         continue; |                                         continue; | ||||||
|                                 } |                                 } | ||||||
|  | ======= | ||||||
|  |                                 { | ||||||
|  |                                         skygw_log_write( | ||||||
|  |                                                 LOGFILE_TRACE, | ||||||
|  |                                                 "%lu [poll_waitevents] dcb is zombie", | ||||||
|  |                                                 pthread_self()); | ||||||
|  |                                         simple_mutex_unlock(mutex); | ||||||
|  |                                         continue; | ||||||
|  |                                 } | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
|  |  | ||||||
| 				if (ev & EPOLLERR) | 				if (ev & EPOLLERR) | ||||||
| 				{ | 				{ | ||||||
| 					atomic_add(&pollStats.n_error, 1); | 					atomic_add(&pollStats.n_error, 1); | ||||||
| 					dcb->func.error(dcb); | 					dcb->func.error(dcb); | ||||||
|  | <<<<<<< TREE | ||||||
| 					if (DCB_ISZOMBIE(dcb)) { | 					if (DCB_ISZOMBIE(dcb)) { | ||||||
|  | ======= | ||||||
|  | 					if (DCB_ISZOMBIE(dcb)) { | ||||||
|  |                                                 simple_mutex_unlock(mutex); | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
| 						continue; | 						continue; | ||||||
|                                         } |                                         } | ||||||
| 				} | 				} | ||||||
| @ -222,7 +252,12 @@ bool                    no_op = FALSE; | |||||||
| 				{ | 				{ | ||||||
| 					atomic_add(&pollStats.n_hup, 1); | 					atomic_add(&pollStats.n_hup, 1); | ||||||
| 					dcb->func.hangup(dcb); | 					dcb->func.hangup(dcb); | ||||||
|  | <<<<<<< TREE | ||||||
| 					if (DCB_ISZOMBIE(dcb)) { | 					if (DCB_ISZOMBIE(dcb)) { | ||||||
|  | ======= | ||||||
|  | 					if (DCB_ISZOMBIE(dcb)) { | ||||||
|  |                                                 simple_mutex_unlock(mutex); | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
| 						continue; | 						continue; | ||||||
|                                         } |                                         } | ||||||
| 				} | 				} | ||||||
| @ -261,8 +296,14 @@ bool                    no_op = FALSE; | |||||||
| 						dcb->func.read(dcb); | 						dcb->func.read(dcb); | ||||||
| 					} | 					} | ||||||
| 				} | 				} | ||||||
|  | <<<<<<< TREE | ||||||
| 			} /**< for */ | 			} /**< for */ | ||||||
|                         no_op = FALSE; |                         no_op = FALSE; | ||||||
|  | ======= | ||||||
|  |                                 simple_mutex_unlock(mutex); | ||||||
|  | 			} /**< for */ | ||||||
|  |                         no_op = FALSE; | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
| 		} | 		} | ||||||
| 		dcb_process_zombies(thread_id); | 		dcb_process_zombies(thread_id); | ||||||
| 		if (shutdown) | 		if (shutdown) | ||||||
|  | |||||||
| @ -134,6 +134,7 @@ typedef struct { | |||||||
|  * gateway may be selected to execute the required actions when a network event occurs. |  * gateway may be selected to execute the required actions when a network event occurs. | ||||||
|  */ |  */ | ||||||
| typedef struct dcb { | typedef struct dcb { | ||||||
|  |         simple_mutex_t  mutex;          /**< Protects dcb processing. Coarse and temporary? */ | ||||||
| 	int		fd;		/**< The descriptor */ | 	int		fd;		/**< The descriptor */ | ||||||
| 	int 		state;		/**< Current descriptor state */ | 	int 		state;		/**< Current descriptor state */ | ||||||
| 	char		*remote;	/**< Address of remote end */ | 	char		*remote;	/**< Address of remote end */ | ||||||
|  | |||||||
| @ -488,6 +488,7 @@ int gw_read_client_event(DCB* dcb) { | |||||||
| 	ROUTER_OBJECT   *router = NULL; | 	ROUTER_OBJECT   *router = NULL; | ||||||
| 	ROUTER          *router_instance = NULL; | 	ROUTER          *router_instance = NULL; | ||||||
| 	void            *rsession = NULL; | 	void            *rsession = NULL; | ||||||
|  | <<<<<<< TREE | ||||||
| 	MySQLProtocol   *protocol = NULL; | 	MySQLProtocol   *protocol = NULL; | ||||||
| 	int             b = -1; | 	int             b = -1; | ||||||
|  |  | ||||||
| @ -500,12 +501,17 @@ int gw_read_client_event(DCB* dcb) { | |||||||
|             spinlock_release(&dcb->writeqlock); |             spinlock_release(&dcb->writeqlock); | ||||||
|             return 1; |             return 1; | ||||||
|         } |         } | ||||||
|  | ======= | ||||||
|  | 	MySQLProtocol   *protocol = NULL; | ||||||
|  | 	int             b = -1; | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
|  |  | ||||||
| 	if (dcb) { | 	if (dcb) { | ||||||
| 		protocol = DCB_PROTOCOL(dcb, MySQLProtocol); | 		protocol = DCB_PROTOCOL(dcb, MySQLProtocol); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if (ioctl(dcb->fd, FIONREAD, &b)) { | 	if (ioctl(dcb->fd, FIONREAD, &b)) { | ||||||
|  | <<<<<<< TREE | ||||||
|             int eno = errno; |             int eno = errno; | ||||||
|             errno = 0; |             errno = 0; | ||||||
|             skygw_log_write( |             skygw_log_write( | ||||||
| @ -520,6 +526,27 @@ int gw_read_client_event(DCB* dcb) { | |||||||
|              |              | ||||||
|             spinlock_release(&dcb->writeqlock);             |             spinlock_release(&dcb->writeqlock);             | ||||||
|             return 1; |             return 1; | ||||||
|  | ======= | ||||||
|  |             int eno = errno; | ||||||
|  |             errno = 0; | ||||||
|  |             skygw_log_write( | ||||||
|  |                     LOGFILE_ERROR, | ||||||
|  |                     "%lu [gw_read_client_event] Setting FIONREAD for %d failed. " | ||||||
|  |                     "errno %d, %s", | ||||||
|  |                     pthread_self(), | ||||||
|  |                     dcb->fd, | ||||||
|  |                     eno , | ||||||
|  |                     strerror(eno)); | ||||||
|  |             skygw_log_write( | ||||||
|  |                     LOGFILE_TRACE, | ||||||
|  |                     "%lu [gw_read_client_event] Setting FIONREAD for %d failed. " | ||||||
|  |                     "errno %d, %s", | ||||||
|  |                     pthread_self(), | ||||||
|  |                     dcb->fd, | ||||||
|  |                     eno , | ||||||
|  |                     strerror(eno)); | ||||||
|  |             return 1; | ||||||
|  | >>>>>>> MERGE-SOURCE | ||||||
| 	} else { | 	} else { | ||||||
| 		//fprintf(stderr, "Client IOCTL FIONREAD bytes to read = %i\n", b); | 		//fprintf(stderr, "Client IOCTL FIONREAD bytes to read = %i\n", b); | ||||||
| 	} | 	} | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Jan Lindström
					Jan Lindström