1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
--- daemon/gvfsbackendsftp.c
+++ daemon/gvfsbackendsftp.c
@@ -24,6 +24,7 @@
#include <config.h>
#include <stdlib.h>
+#include <sys/poll.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
@@ -852,6 +853,9 @@ handle_login (GVfsBackend *backend,
const gchar *authtype = NULL;
gchar *object = NULL;
char *prompt;
+ /*
+ * TODO: compare this with sshfs.c where the prompt appears on stdin_fd
+ */
if (op_backend->client_vendor == SFTP_VENDOR_SSH)
prompt_fd = stderr_fd;
@@ -864,14 +868,13 @@ handle_login (GVfsBackend *backend,
ret_val = TRUE;
while (1)
{
- FD_ZERO (&ifds);
- FD_SET (stdout_fd, &ifds);
- FD_SET (prompt_fd, &ifds);
-
- tv.tv_sec = SFTP_READ_TIMEOUT;
- tv.tv_usec = 0;
+ struct pollfd fds[2];
+ fds[0].fd = stdout_fd;
+ fds[0].events = POLLIN;
+ fds[1].fd = prompt_fd;
+ fds[1].events = POLLIN;
- ret = select (MAX (stdout_fd, prompt_fd)+1, &ifds, NULL, NULL, &tv);
+ ret = poll(fds, 2, SFTP_READ_TIMEOUT);
if (ret <= 0)
{
@@ -882,11 +885,11 @@ handle_login (GVfsBackend *backend,
break;
}
- if (FD_ISSET (stdout_fd, &ifds))
+ if (fds[0].revents)
break; /* Got reply to initial INIT request */
- g_assert (FD_ISSET (prompt_fd, &ifds));
-
+ if (!(fds[1].revents & POLLIN))
+ continue;
len = g_input_stream_read (prompt_stream,
buffer, sizeof (buffer) - 1,
|