]> rtime.felk.cvut.cz Git - frescor/fwp.git/blobdiff - wme_test/wclient.c
wme_test: recv_packet_fwp returns correct value
[frescor/fwp.git] / wme_test / wclient.c
index 9bcc8e8e77296b87fb6cef95db55aa89b97096eb..708c28e5dc8db449654350fdb7e22251fd8b4fd1 100644 (file)
 #include <inttypes.h>
 #include <ncurses.h>
 
+#ifdef WITH_FWP
+#include <ul_logreg.h>
+#endif
+
 #ifdef WITH_FWP
 #include <frsh.h>
 #include <fwp_res.h>
@@ -393,9 +397,10 @@ int recv_packet_native(intptr_t ac, struct msg_t *msg)
 #else
 int recv_packet_fwp(struct stream *stream, struct msg_t *msg)
 {
+       int ret;
        size_t mlen;
 
-       mlen = frsh_receive_sync(stream->resp_endpoint, msg, sizeof(*msg), &mlen, NULL);
+       ret = frsh_receive_sync(stream->resp_endpoint, msg, sizeof(*msg), &mlen, NULL);
        return mlen;
 }
 #endif
@@ -530,7 +535,12 @@ send_packet_fwp(struct stream* stream, union msg_buff* buff)
        int ret = 0;
 
        buff->msg.resp_port = htons(stream->resp_port);
-       ret = frsh_send_sync(stream->endpoint, buff, stream->packet_size);
+       ret = frsh_send_async(stream->endpoint, buff, stream->packet_size);
+       if (ret) {
+               char msg[1024];
+               frsh_strerror(ret, msg, sizeof(msg));
+               fprintf(stderr, "frsh_send error: %s\n", msg);
+       }
        return (ret == 0) ? 0 : -1;
 }
 #endif
@@ -590,6 +600,7 @@ void* sender(void* arg)
 
                ret = send_packet(stream, &buff);
                if (ret < 0) {
+                       stopper();
                        goto out;
                }
 
@@ -993,6 +1004,13 @@ void print_status_nogui(int seconds)
        fflush(stderr);
 }
 
+#ifdef WITH_FWP
+int print_log_domain(ul_log_domain_t *domain, void *context)
+{
+       printf("%s = %d\n", domain->name, domain->level);
+       return 0;
+}
+#endif
 int main(int argc, char *argv[])
 {
        int i, rc, frames, seconds;
@@ -1001,7 +1019,7 @@ int main(int argc, char *argv[])
        char opt;
 
 
-       while ((opt = getopt(argc, argv, "B:b:C:c:Gg:I:j:o:qQ:s:T:")) != -1) {
+       while ((opt = getopt(argc, argv, "B:b:C:c:Gg:I:j:l:o:qQ:s:T:")) != -1) {
                switch (opt) {
                        case 'B':
                                opt_def_bandwidth = atoi(optarg);
@@ -1042,6 +1060,20 @@ int main(int argc, char *argv[])
                                opt_jitter = atoi(optarg);
                                #endif
                                break;
+#ifdef WITH_FWP
+                       case 'l':
+                               if (*optarg == '?') {
+                                       ul_logreg_for_each_domain(print_log_domain, NULL);
+                                       exit(0);
+                               }
+                               {
+                                       int ret;
+                                       ret = ul_log_domain_arg2levels(optarg);
+                                       if (ret) 
+                                               error(1, EINVAL, "Error parsing -l argument at char %d\n", ret);
+                               }
+                               break;
+#endif
                        case 'o':
                                opt_output = optarg;
                                break;
@@ -1065,7 +1097,11 @@ int main(int argc, char *argv[])
                                fprintf(stderr, "    -C  comment (added to header)\n");
                                fprintf(stderr, "    -c  count (number of seconds to run)\n");
                                fprintf(stderr, "    -g  histogram granularity [usec]\n");
+                               fprintf(stderr, "    -G  show status in textual GUI\n");
                                fprintf(stderr, "    -I  <interface> send packets from this interface\n");
+#ifdef WITH_FWP
+                               fprintf(stderr, "    -l  <loglevel> uLUt logging levels\n");
+#endif
                                fprintf(stderr, "    -j  send jitter (0-100) [%%]\n");
                                fprintf(stderr, "    -o  output filename (.dat will be appended)\n");
                                fprintf(stderr, "    -q  gather statistics only after some queue becomes full\n");
@@ -1186,6 +1222,10 @@ int main(int argc, char *argv[])
        }
 
        end_gui();
+
+       fprintf(stderr, "\nWaiting for threads to finish\n");
+       wait_for_all_threads_to_finish();
+
 #ifdef WITH_FWP
        for (i=0; i < nr_streams; i++) {
                if (streams[i].vres)
@@ -1195,9 +1235,6 @@ int main(int argc, char *argv[])
        }
 #endif
 
-       fprintf(stderr, "\nWaiting for threads to finish\n");
-       wait_for_all_threads_to_finish();
-
        struct timespec ts;
        uint64_t end_timestamp, measure_length;
        clock_gettime(CLOCK_REALTIME,&ts);