Commit e105df67 e105df67dcc3f11787259c6334e68a9dabb167c1 by Sergey Poznyakoff

Bugfix.

* examples/http.c (main): Fix open/wait loop.
* libmailutils/stream.c (mu_stream_wait): May be used
on not-open streams.
* examples/.gitignore: Add more files.
1 parent aa082652
...@@ -15,8 +15,10 @@ mimetest ...@@ -15,8 +15,10 @@ mimetest
15 msg-send 15 msg-send
16 mta 16 mta
17 muauth 17 muauth
18 mucat
18 muemail 19 muemail
19 murun 20 murun
21 musocio
20 nntpclient 22 nntpclient
21 pop3client 23 pop3client
22 sfrom 24 sfrom
......
...@@ -99,12 +99,14 @@ main (int argc, char **argv) ...@@ -99,12 +99,14 @@ main (int argc, char **argv)
99 99
100 for (attempt = 0; ret; ) 100 for (attempt = 0; ret; )
101 { 101 {
102 ret = mu_stream_open (stream);
103 if ((ret == EAGAIN || ret == EINPROGRESS) && attempt < io_attempts) 102 if ((ret == EAGAIN || ret == EINPROGRESS) && attempt < io_attempts)
104 { 103 {
105 ret = http_stream_wait(stream, MU_STREAM_READY_WR, &attempt); 104 ret = http_stream_wait(stream, MU_STREAM_READY_WR, &attempt);
106 if (ret == 0) 105 if (ret == 0)
107 continue; 106 {
107 ret = mu_stream_open (stream);
108 continue;
109 }
108 } 110 }
109 mu_error ("mu_stream_open: %s", mu_strerror (ret)); 111 mu_error ("mu_stream_open: %s", mu_strerror (ret));
110 exit (EXIT_FAILURE); 112 exit (EXIT_FAILURE);
......
...@@ -1071,14 +1071,18 @@ mu_stream_wait (mu_stream_t stream, int *pflags, struct timeval *tvp) ...@@ -1071,14 +1071,18 @@ mu_stream_wait (mu_stream_t stream, int *pflags, struct timeval *tvp)
1071 1071
1072 if (stream == NULL) 1072 if (stream == NULL)
1073 return EINVAL; 1073 return EINVAL;
1074 1074 #if 0
1075 /* NOTE: Sometimes mu_stream_wait is called after a failed mu_stream_open.
1076 In particular, this is needed for a TCP stream opened with a
1077 MU_STREAM_NONBLOCK flag (see examples/http.c). Until a better
1078 solution is found, this check is commented out. */
1075 if (!(stream->flags & _MU_STR_OPEN)) 1079 if (!(stream->flags & _MU_STR_OPEN))
1076 { 1080 {
1077 if (stream->open) 1081 if (stream->open)
1078 return MU_ERR_NOT_OPEN; 1082 return MU_ERR_NOT_OPEN;
1079 _stream_init (stream); 1083 _stream_init (stream);
1080 } 1084 }
1081 1085 #endif
1082 /* Take to acount if we have any buffering. */ 1086 /* Take to acount if we have any buffering. */
1083 /* FIXME: How about MU_STREAM_READY_WR? */ 1087 /* FIXME: How about MU_STREAM_READY_WR? */
1084 if ((*pflags) & MU_STREAM_READY_RD 1088 if ((*pflags) & MU_STREAM_READY_RD
......