diff options
| -rwxr-xr-x | vchat-client.c | 4 | ||||
| -rw-r--r-- | vchat-connection.c | 13 | ||||
| -rw-r--r-- | vchat-connection.h | 2 |
3 files changed, 7 insertions, 12 deletions
diff --git a/vchat-client.c b/vchat-client.c index c094376..d1afaa2 100755 --- a/vchat-client.c +++ b/vchat-client.c | |||
| @@ -397,8 +397,8 @@ void eventloop(void) { | |||
| 397 | userinput(); | 397 | userinput(); |
| 398 | 398 | ||
| 399 | /* something to read from server? */ | 399 | /* something to read from server? */ |
| 400 | if (poll_result & 2) | 400 | if ((poll_result & 2) && vc_receive()) |
| 401 | vc_receive(); | 401 | status = 0; |
| 402 | break; | 402 | break; |
| 403 | } | 403 | } |
| 404 | } | 404 | } |
diff --git a/vchat-connection.c b/vchat-connection.c index 9770115..7c204fd 100644 --- a/vchat-connection.c +++ b/vchat-connection.c | |||
| @@ -35,10 +35,6 @@ | |||
| 35 | static int serverfd = -1; | 35 | static int serverfd = -1; |
| 36 | unsigned int want_tcp_keepalive = 0; | 36 | unsigned int want_tcp_keepalive = 0; |
| 37 | 37 | ||
| 38 | /* TODO: NEEDS TO GO. status-variable from vchat-client.c | ||
| 39 | * eventloop is done as long as this is true */ | ||
| 40 | extern int status; | ||
| 41 | |||
| 42 | /* Generic tcp connector, blocking */ | 38 | /* Generic tcp connector, blocking */ |
| 43 | static int connect_tcp_socket(const char *server, const char *port) { | 39 | static int connect_tcp_socket(const char *server, const char *port) { |
| 44 | struct addrinfo hints, *res, *res0; | 40 | struct addrinfo hints, *res, *res0; |
| @@ -215,15 +211,14 @@ void vc_receive(void) { | |||
| 215 | /* Our tls functions may require retries with handshakes etc, this is | 211 | /* Our tls functions may require retries with handshakes etc, this is |
| 216 | * signalled by -2 */ | 212 | * signalled by -2 */ |
| 217 | if (bytes == -2) | 213 | if (bytes == -2) |
| 218 | return; | 214 | return 0; |
| 219 | 215 | ||
| 220 | /* Error on the socket read? raise error message, bail out */ | 216 | /* Error on the socket read? raise error message, bail out */ |
| 221 | if (bytes == -1) { | 217 | if (bytes == -1) { |
| 222 | snprintf(tmpstr, TMPSTRSIZE, "Receive fails, %s.", strerror(errno)); | 218 | snprintf(tmpstr, TMPSTRSIZE, "Receive fails, %s.", strerror(errno)); |
| 223 | snprintf(errstr, ERRSTRSIZE, "Receive fails, %s.\n", strerror(errno)); | 219 | snprintf(errstr, ERRSTRSIZE, "Receive fails, %s.\n", strerror(errno)); |
| 224 | writecf(FS_ERR, tmpstr); | 220 | writecf(FS_ERR, tmpstr); |
| 225 | status = 0; | 221 | return -1; |
| 226 | return; | ||
| 227 | } | 222 | } |
| 228 | 223 | ||
| 229 | /* end of file from server? */ | 224 | /* end of file from server? */ |
| @@ -231,8 +226,7 @@ void vc_receive(void) { | |||
| 231 | /* inform user, bail out */ | 226 | /* inform user, bail out */ |
| 232 | writecf(FS_SERV, "* EOF from server."); | 227 | writecf(FS_SERV, "* EOF from server."); |
| 233 | snprintf(errstr, ERRSTRSIZE, "* EOF from server.\n"); | 228 | snprintf(errstr, ERRSTRSIZE, "* EOF from server.\n"); |
| 234 | status = 0; | 229 | return -1; |
| 235 | return; | ||
| 236 | } | 230 | } |
| 237 | 231 | ||
| 238 | buf_fill += bytes; | 232 | buf_fill += bytes; |
| @@ -257,4 +251,5 @@ void vc_receive(void) { | |||
| 257 | buf_fill -= 1 + endmsg - buf; | 251 | buf_fill -= 1 + endmsg - buf; |
| 258 | memmove(buf, endmsg + 1, buf_fill); | 252 | memmove(buf, endmsg + 1, buf_fill); |
| 259 | } | 253 | } |
| 254 | return 0; | ||
| 260 | } | 255 | } |
diff --git a/vchat-connection.h b/vchat-connection.h index 9b3ccaa..2889c82 100644 --- a/vchat-connection.h +++ b/vchat-connection.h | |||
| @@ -4,6 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | int vc_connect(const char *host, const char *port); | 5 | int vc_connect(const char *host, const char *port); |
| 6 | void vc_sendmessage(const char *message); | 6 | void vc_sendmessage(const char *message); |
| 7 | void vc_receive(); | 7 | int vc_receive(); |
| 8 | int vc_poll(); | 8 | int vc_poll(); |
| 9 | void vc_disconnect(); | 9 | void vc_disconnect(); |
