Przeglądaj źródła

Z991240-991 #comment bugfix:解决bizchan连线接收失败问题

胡琛80272472 4 lat temu
rodzic
commit
7e3470feeb

+ 3 - 3
Module/mod_assistantchannel/chan_protocol.h

@@ -52,9 +52,9 @@ typedef struct acm_hdr {
 	unsigned char encrypt : 1;
 	unsigned char error : 7;
 	unsigned short sub_type;
-	unsigned long length; // 需要注意的是长度最大为2^16-1,65535
-	unsigned long id; // 包id
-	unsigned long hash;
+	unsigned int length; // 需要注意的是长度最大为2^16-1,65535
+	unsigned int id; // 包id
+	unsigned int hash;
 	unsigned char data[0]; // 长度由length决定
 }acm_hdr;
 typedef struct proxy_hdr {

+ 8 - 5
Other/libbizchan/bizchan.cpp

@@ -540,6 +540,8 @@ static int on_recv(bizchan_t *chan, SOCKET conn)
 	else {
 		result = (n < 0 || (errno == EWOULDBLOCK) || (errno == EINTR) || (errno == EAGAIN)) ? 0 : -1;
 	}
+	snprintf(buffer, 128, "on_recv n:%d, result:%d, errno:%d", n, result, errno);
+	chan->cb.dbg(chan, 0, buffer, chan->cb.user_data);
 	return result;
 #endif
 }
@@ -941,17 +943,17 @@ static void do_shake_recv(bizchan_t* chan, SOCKET conn, int* error) {
 				decodefun((unsigned char*)&chan->remote_pwd[0], sizeof(chan->remote_pwd), (unsigned char*)&ack_hdr.encrypt_key[0], sizeof(ack_hdr.encrypt_key));
 				chan->cb.dbg(chan, 0, "do_shake_recv remote_pwd:", chan->cb.user_data);
 				chan->cb.dbg(chan, 0, chan->remote_pwd, chan->cb.user_data);
-				//if (check_hash(chan->remote_pwd, sizeof(chan->remote_pwd), ack_hdr.encrypt_keyhash)) {
+				if (check_hash(chan->remote_pwd, sizeof(chan->remote_pwd), ack_hdr.encrypt_keyhash)) {
 					chan->remote_video_rtp_port = ack_hdr.rtp_port;
 					chan->remote_video_desc = ack_hdr.media_desc;
 					memcpy(chan->remote_client_id, ack_hdr.client_id, sizeof(chan->remote_client_id));
 					chan->connected = TRUE;
 					break;
-				/*}
+				}
 				else {
 					*error = -1;
 					chan->cb.dbg(chan, 0, "do_shake_recv check_hash failed", chan->cb.user_data);
-				}*/
+				}
 			}
 		}
 	} while (t > 0 && *error == 0);
@@ -977,6 +979,7 @@ static void  build_fd_sets(SOCKET conn, int evt, fd_set* read_fds, fd_set* write
 	//FD_SET(conn, write_fds);
 	FD_ZERO(except_fds);
 	FD_SET(conn, except_fds);
+	FD_SET(evt, except_fds);
 }
 
 static int set_socket_noblock(SOCKET socket) {
@@ -1127,13 +1130,13 @@ static void process(bizchan_t* chan) {
 			int activity = select(maxfd + 1, &read_fds, &write_fds, &except_fds, &tv);
 			if (activity == -1) {
 				perror("select()");
-				chan->cb.dbg(chan, 0, "select() error.", chan->cb.user_data);
+				chan->cb.dbg(chan, 0, "chan select() error.", chan->cb.user_data);
 				goto on_error;
 			}
 			else if (activity == 0) {
 				// timeout 
 				printf("select() returns 0, timeout.\n");
-				chan->cb.dbg(chan, 0, "select() returns 0, timeout.", chan->cb.user_data);
+				//chan->cb.dbg(chan, 0, "select() returns 0, timeout.", chan->cb.user_data);
 				LARGE_INTEGER now;
 				GetTick(&chan->last_remote_active_time, &now);
 				if (now.QuadPart - chan->last_remote_active_time.QuadPart >= PING_INTERVAL) {