|
|
@@ -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) {
|