1271 |
int |
int |
1272 |
ui_select(int rdp_socket) |
ui_select(int rdp_socket) |
1273 |
{ |
{ |
1274 |
int n = (rdp_socket > g_x_socket) ? rdp_socket + 1 : g_x_socket + 1; |
int n = (rdp_socket > g_x_socket) ? rdp_socket : g_x_socket; |
1275 |
fd_set rfds, wfds; |
fd_set rfds, wfds; |
1276 |
|
struct timeval tv; |
1277 |
|
BOOL s_timeout = False; |
1278 |
|
|
1279 |
while (True) |
while (True) |
1280 |
{ |
{ |
1293 |
if (g_dsp_busy) |
if (g_dsp_busy) |
1294 |
{ |
{ |
1295 |
FD_SET(g_dsp_fd, &wfds); |
FD_SET(g_dsp_fd, &wfds); |
1296 |
n = (g_dsp_fd + 1 > n) ? g_dsp_fd + 1 : n; |
n = (g_dsp_fd > n) ? g_dsp_fd : n; |
1297 |
} |
} |
1298 |
#endif |
#endif |
1299 |
|
/* default timeout */ |
1300 |
|
tv.tv_sec = 60; |
1301 |
|
tv.tv_usec = 0; |
1302 |
|
|
1303 |
switch (select(n, &rfds, &wfds, NULL, NULL)) |
/* add redirection handles */ |
1304 |
|
rdpdr_add_fds(&n, &rfds, &wfds, &tv, &s_timeout); |
1305 |
|
|
1306 |
|
n++; |
1307 |
|
|
1308 |
|
switch (select(n, &rfds, &wfds, NULL, &tv)) |
1309 |
{ |
{ |
1310 |
case -1: |
case -1: |
1311 |
error("select: %s\n", strerror(errno)); |
error("select: %s\n", strerror(errno)); |
1312 |
|
|
1313 |
case 0: |
case 0: |
1314 |
|
s_timeout = True; |
1315 |
|
rdpdr_check_fds(&rfds, &wfds, (BOOL) True); |
1316 |
continue; |
continue; |
1317 |
} |
} |
1318 |
|
|
1319 |
|
rdpdr_check_fds(&rfds, &wfds, (BOOL) False); |
1320 |
|
|
1321 |
if (FD_ISSET(rdp_socket, &rfds)) |
if (FD_ISSET(rdp_socket, &rfds)) |
1322 |
return 1; |
return 1; |
1323 |
|
|