A typo and a couple of logic errors fixed. I think there may still be one
[openssl.git] / demos / tunala / tunala.c
index 445940fabd5badc9b9631ed08fb74fbc73160fab..cc32adc0500503ea31bfbf2dd6910bccd6fac262 100644 (file)
@@ -84,15 +84,6 @@ static int tunala_item_io(tunala_selector_t *selector, tunala_item_t *item);
 /* MAIN FUNCTION (and its utility functions) */
 /*********************************************/
 
-/* For now, hard-coded as follows;
- * (a) We're like "tunala -listen 127.0.0.1:9001 -proxy 127.0.0.1:9002"
- * (b) We max out at 50 simultaneous tunnels, listening will stop while we have
- *     that many tunnels operating and will recommence as/when tunnels close.
- * (c) We are an SSL client proxy
- * (d) We use the "openssl" ENGINE
- * (e) We use the CA cert file "cacert.pem"
- * */
-
 static const char *def_proxyhost = "127.0.0.1:443";
 static const char *def_listenhost = "127.0.0.1:8080";
 static int def_max_tunnels = 50;
@@ -304,7 +295,7 @@ main_loop:
                fprintf(stderr, "selector_select returned a badness error.\n");
                abort();
        case 0:
-               fprintf(stderr, "Warn, selector_select return 0 - signal??\n");
+               fprintf(stderr, "Warn, selector_select returned 0 - signal??\n");
                goto main_loop;
        default:
                break;
@@ -687,7 +678,7 @@ static int tunala_item_io(tunala_selector_t *selector, tunala_item_t *item)
                        item->clean_send = -1;
                item->clean_read = -1;
        }
-       if(c_s) {
+       if(c_s && (item->clean_send != -1)) {
                close(item->clean_send);
                if(item->clean_send == item->clean_read)
                        item->clean_read = -1;
@@ -699,7 +690,7 @@ static int tunala_item_io(tunala_selector_t *selector, tunala_item_t *item)
                        item->dirty_send = -1;
                item->dirty_read = -1;
        }
-       if(d_s) {
+       if(d_s && (item->dirty_send != -1)) {
                close(item->dirty_send);
                if(item->dirty_send == item->dirty_read)
                        item->dirty_read = -1;