improve error handling
diff --git a/programs/http_client.c b/programs/http_client.c
index 69f31e7..ac52619 100644
--- a/programs/http_client.c
+++ b/programs/http_client.c
@@ -258,6 +258,8 @@
if (errno == ECONNREFUSED) {
result = RETVAL_ECONNREFUSED;
+ } else if (errno == ETIMEDOUT) {
+ result = RETVAL_TIMEOUT;
} else {
result = RETVAL_CATCHALL;
}
diff --git a/programs/http_client_upcall.c b/programs/http_client_upcall.c
index 5f08bb2..a475de9 100644
--- a/programs/http_client_upcall.c
+++ b/programs/http_client_upcall.c
@@ -53,8 +53,8 @@
#include <usrsctp.h>
#define RETVAL_CATCHALL 50
-#define RETVAL_ECONNREFUSED 60
-#define RETVAL_TIMEOUT 61
+#define RETVAL_TIMEOUT 60
+#define RETVAL_ECONNREFUSED 61
int done = 0;
int writePending = 1;
@@ -93,7 +93,13 @@
if (n < 0) {
perror("usrsctp_recvv");
- result = errno;
+ if (errno == ECONNREFUSED) {
+ result = RETVAL_ECONNREFUSED;
+ } else if (errno == ETIMEDOUT) {
+ result = RETVAL_TIMEOUT;
+ } else {
+ result = RETVAL_CATCHALL;
+ }
}
if (n <= 0){
@@ -301,6 +307,8 @@
if (errno == ECONNREFUSED) {
result = RETVAL_ECONNREFUSED;
+ } else if (errno == ETIMEDOUT) {
+ result = RETVAL_TIMEOUT;
} else {
result = RETVAL_CATCHALL;
}
@@ -323,5 +331,7 @@
sleep(1);
#endif
}
+
+ printf("returning: %d\n", result);
return (result);
}