From 794acdd7e45b2305f25fdddc6fd43e7648216807 Mon Sep 17 00:00:00 2001
From: wangzhengquan <wangzhengquan85@126.com>
Date: 星期二, 16 六月 2020 17:14:57 +0800
Subject: [PATCH] move ipc

---
 /dev/null               |    6 ------
 service/test_client     |    0 
 common/libusgcommon.a   |    0 
 common/Makefile         |    4 +++-
 service/netdisk_service |    0 
 service/test_queue      |    0 
 common/libusgcommon.so  |    0 
 service/test_properties |    0 
 service/test            |    0 
 9 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/bipc/Makefile b/bipc/Makefile
deleted file mode 100644
index d7e7051..0000000
--- a/bipc/Makefile
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Makefile for common library.
-#
-ROOT=..
-# LDLIBS+=-Wl,-rpath=
-# 娴峰悍鍖呰矾寰�
-# 寮�婧愬伐鍏峰寘璺緞
-LDDIR +=-L$(ROOT)/lib/nng
- 
-# 寮�婧愬伐鍏峰寘
-LDLIBS += -lnng -lpthread
-
-#LIB_NETDISK = $(ROOT)/libnetdisk.a
-#DLIB_NETDISK = $(ROOT)/libnetdisk.so
-PLATFORM=$(shell $(ROOT)/systype.sh)
-include $(ROOT)/Make.defines.$(PLATFORM)
-
- 
-PROGS = test_survey test_survey2 test_pubsub test_pullpush test_pair test_bus test_reqrep
-
-
-build: $(PROGS)
-
-
-test_survey: test_survey.c bipc.c
- 
-test_pubsub:  test_pubsub.c bipc.c
-
-test_pullpush:  test_pullpush.c bipc.c
-
-test_pair: test_pair.c bipc.c
-
-test_bus:  test_bus.c bipc.c
-
-test_reqrep: test_reqrep.c bipc.c
-
-clean:
-	rm -f $(TEMPFILES) $(PROGS)
-
-
-include $(ROOT)/Make.common.inc
diff --git a/bipc/bipc.c b/bipc/bipc.c
deleted file mode 100644
index a7ae9e0..0000000
--- a/bipc/bipc.c
+++ /dev/null
@@ -1,144 +0,0 @@
-#include "bipc.h"
-#include <nng/protocol/pipeline0/pull.h>
-#include <nng/protocol/pipeline0/push.h>
-#include <nng/protocol/survey0/survey.h>
-#include <nng/protocol/survey0/respond.h>
-#include <nng/protocol/pubsub0/pub.h>
-#include <nng/protocol/pubsub0/sub.h>
-#include <nng/protocol/pair0/pair.h>
-#include <nng/protocol/bus0/bus.h>
-#include <nng/protocol/reqrep0/rep.h>
-#include <nng/protocol/reqrep0/req.h>
-
-void
-static fatal(const char *func, int rv)
-{
-        fprintf(stderr, "%s: %s\n", func, nng_strerror(rv));
-        exit(1);
-}
-
-int  bipc_listen(bipc_socket_t *sock, const char *url, bipc_mod_t mod) {
-	 
-	int rv;
-	switch(mod) {
-		case PULL_PUSH:
-			rv = nng_pull0_open(sock);
-			 break;
-	    case PAIR:
-	    	rv = nng_pair0_open(sock);
-	        break;
-	    case BUS:
-	    	rv = nng_bus0_open(sock);
-	    	break;
-	    case REQ_REP:
-	    	rv = nng_rep0_open(sock);
-	    	break;
-	    case SURVEY:
-	    	rv = nng_surveyor0_open(sock);
-	    	break;
-	    case PUB_SUB:
-	    	rv = nng_pub0_open(sock);
-	    	break;
-	    default:
-	    	fprintf(stderr, "鏃犳硶璇嗗埆鐨勬ā寮�");
-	    	return -1;
-	}
-
-	if (rv != 0) {
-	   // fatal("open", rv);
-	    return rv;
-	}
-
-	if ((rv = nng_listen(*sock, url, NULL, 0)) != 0) {
-       // fatal("nng_listen", rv);
-        return rv;
-    }
-	return 0;
-
-}
-
-int bipc_connect(bipc_socket_t *sock, const char *url, bipc_mod_t mod) {
-	int rv  = 0 ;
-	switch(mod) {
-		case PULL_PUSH:
-			rv = nng_push0_open(sock);
-			break;
-	    case PAIR:
-	    	rv = nng_pair0_open(sock);
-	        break;
-	    case BUS:
-	    	break;
-	    case REQ_REP:
-	    	rv = nng_req0_open(sock);
-	    	break;
-	    case SURVEY:
-	    	rv = nng_respondent0_open(sock);
-	    	break;
-	    case PUB_SUB:
-	    	if ((rv = nng_sub0_open(sock)) != 0) {
-                //fatal("sub0_open", rv);
-                return rv;
-        	}
-	    	if ((rv = nng_setopt(*sock, NNG_OPT_SUB_SUBSCRIBE, "", 0)) != 0) {
-                //fatal("nng_setopt", rv);
-                return rv;
-        	}
-	    	break;
-	    default:
-	    	fprintf(stderr, "鏃犳硶璇嗗埆鐨勬ā寮�");
-	    	return rv;
-	}
-
-	if (rv != 0) {
-        fatal("bipc_connect open socket", rv);
-        return rv;
-    }
-
-	if ((rv = nng_dial(*sock, url, NULL, 0)) != 0) {
-       // fatal("dial", rv);
-        return rv;
-    }
-    return 0;
-}
-
-int bipc_send(bipc_socket_t *sock,  const void *data, size_t size) {
-    return nng_send(*sock, const_cast<void *>(data), size, 0);
-}
-
-
-int bipc_recv(bipc_socket_t *sock,  void *data, size_t *sizep) {
-	
-	//int rv = nng_recv(*sock, data, sizep, 0);
-	// char *buf = NULL;
-	// int rv = nng_recv(*sock, &buf, sizep, NNG_FLAG_ALLOC);
-	// memcpy(data, buf, *sizep);
-	// nng_free(buf, *sizep);
-	int rv = nng_recv(*sock, data, sizep, NNG_FLAG_ALLOC);
-	if (rv == NNG_ETIMEDOUT)
-		return BIPC_ETIMEDOUT ;
-	
-	return rv;
-}
-
-int bipc_setopt(bipc_socket_t *s, const char *opt, const void *val, size_t valsz) {
-	const char *tmp_opt;
-	if(strcmp(opt, BIPC_OPT_RECVTIMEO) == 0) {
-		tmp_opt = NNG_OPT_RECVTIMEO;
-	}
-	return nng_setopt(*s, tmp_opt, val, valsz);
-}
-
-void bipc_free(void *ptr, size_t size) {
-	 nng_free(ptr, size);
-}
-
-
-int bipc_close(bipc_socket_t *s){
-	return nng_close(*s);
-}
-
-
-
-const char * bipc_strerror(int error) {
-	return nng_strerror(error);
-}
\ No newline at end of file
diff --git a/bipc/bipc.h b/bipc/bipc.h
deleted file mode 100644
index 9ae0994..0000000
--- a/bipc/bipc.h
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <nng/nng.h>
-
-
-enum bipc_mod_t
-{
-	PULL_PUSH = 1,
-	REQ_REP = 2,
-	PAIR = 3,
-	PUB_SUB = 4,
-	SURVEY = 5,
-	BUS = 6
-	
-};
-
-enum bipc_err {
-	BIPC_ETIMEDOUT = 5
-};
-
-
-#define BIPC_OPT_SOCKNAME      "socket-name"
-#define BIPC_OPT_RAW           "raw"
-#define BIPC_OPT_PROTO         "protocol"
-#define BIPC_OPT_PROTONAME     "protocol-name"
-#define BIPC_OPT_PEER          "peer"
-#define BIPC_OPT_PEERNAME      "peer-name"
-#define BIPC_OPT_RECVBUF       "recv-buffer"
-#define BIPC_OPT_SENDBUF       "send-buffer"
-#define BIPC_OPT_RECVFD        "recv-fd"
-#define BIPC_OPT_SENDFD        "send-fd"
-#define BIPC_OPT_RECVTIMEO     "recv-timeout"
-#define BIPC_OPT_SENDTIMEO     "send-timeout"
-#define BIPC_OPT_LOCADDR       "local-address"
-#define BIPC_OPT_REMADDR       "remote-address"
-#define BIPC_OPT_URL           "url"
-#define BIPC_OPT_MAXTTL        "ttl-max"
-#define BIPC_OPT_RECVMAXSZ     "recv-size-max"
-#define BIPC_OPT_RECONNMINT    "reconnect-time-min"
-#define BIPC_OPT_RECONNMAXT    "reconnect-time-max"
-
-
-typedef nng_socket bipc_socket_t;
-
-int bipc_listen(bipc_socket_t *sock, const char *url, bipc_mod_t mod);
-
-int bipc_connect(bipc_socket_t *sock, const char *url, bipc_mod_t mod);
-
-int bipc_send(bipc_socket_t *sock,  const void *data, size_t size);
-
-int bipc_recv(bipc_socket_t *sock,  void *data, size_t *sizep);
-
-int bipc_setopt(bipc_socket_t *s, const char *opt, const void *val, size_t valsz);
-
-void bipc_free(void *ptr, size_t size);
-
-int bipc_close(bipc_socket_t *s);
-
-const char * bipc_strerror(int error);
\ No newline at end of file
diff --git a/bipc/test_bus b/bipc/test_bus
deleted file mode 100755
index 567d137..0000000
--- a/bipc/test_bus
+++ /dev/null
Binary files differ
diff --git a/bipc/test_bus.c b/bipc/test_bus.c
deleted file mode 100644
index a6189b4..0000000
--- a/bipc/test_bus.c
+++ /dev/null
@@ -1,74 +0,0 @@
-#include "bipc.h"
-
-
-void
-fatal(const char *func, int rv)
-{
-  fprintf(stderr, "%s: %s\n", func, bipc_strerror(rv));
-  exit(1);
-}
-
-int
-node(int argc, char **argv)
-{
-  bipc_socket_t sock;
-  int rv;
-  size_t sz;
-
-
-  if ((rv = bipc_listen(&sock, argv[2], BUS)) != 0)
-  {
-    fatal("nng_listen", rv);
-  }
-
-  sleep(1); // wait for peers to bind
-  if (argc >= 3)
-  {
-    for (int x = 3; x < argc; x++)
-    {
-      if ((rv = bipc_connect(&sock, argv[x], BUS)) != 0)
-      {
-        fatal("nng_dial", rv);
-      }
-    }
-  }
-
-  sleep(1); // wait for connects to establish
-
-  // SEND
-  sz = strlen(argv[1]) + 1; // '\0' too
-  printf("%s: SENDING '%s' ONTO BUS\n", argv[1], argv[1]);
-  if ((rv = bipc_send(&sock, argv[1], sz)) != 0)
-  {
-    fatal("nng_send", rv);
-  }
-
-  // RECV
-  for (;;)
-  {
-    char *buf = NULL;
-    size_t sz;
-    if ((rv = bipc_recv(&sock, &buf, &sz)) != 0)
-    {
-      if (rv == BIPC_ETIMEDOUT)
-      {
-        fatal("nng_recv", rv);
-      }
-    }
-    printf("%s: RECEIVED '%s' FROM BUS\n", argv[1], buf);
-    bipc_free(buf, sz);
-  }
-  bipc_close(&sock);
-  return (0);
-}
-
-int
-main(int argc, char **argv)
-{
-  if (argc >= 3)
-  {
-    return (node(argc, argv));
-  }
-  fprintf(stderr, "Usage: bus <NODE_NAME> <URL> <URL> ...\n");
-  return 1;
-}
diff --git a/bipc/test_bus.sh b/bipc/test_bus.sh
deleted file mode 100755
index abbea42..0000000
--- a/bipc/test_bus.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-./test_bus node0 ipc:///tmp/node0.ipc ipc:///tmp/node1.ipc ipc:///tmp/node2.ipc & node0=$!
-./test_bus node1 ipc:///tmp/node1.ipc ipc:///tmp/node2.ipc ipc:///tmp/node3.ipc & node1=$!
-./test_bus node2 ipc:///tmp/node2.ipc ipc:///tmp/node3.ipc & node2=$!
-./test_bus node3 ipc:///tmp/node3.ipc ipc:///tmp/node0.ipc & node3=$!
-sleep 5
-kill $node0 $node1 $node2 $node3
\ No newline at end of file
diff --git a/bipc/test_pair b/bipc/test_pair
deleted file mode 100755
index 2b3d903..0000000
--- a/bipc/test_pair
+++ /dev/null
Binary files differ
diff --git a/bipc/test_pair.c b/bipc/test_pair.c
deleted file mode 100644
index 8ed4a41..0000000
--- a/bipc/test_pair.c
+++ /dev/null
@@ -1,93 +0,0 @@
-#include "bipc.h"
-
-#define NODE0 "node0"
-#define NODE1 "node1"
-
-void
-fatal(const char *func, int rv)
-{
-        fprintf(stderr, "%s: %s\n", func, bipc_strerror(rv));
-        exit(1);
-}
-
-int
-send_name(bipc_socket_t sock, const char *name)
-{
-        int rv;
-        printf("%s: SENDING \"%s\"\n", name, name);
-        if ((rv = bipc_send(&sock, name, strlen(name) + 1)) != 0) {
-                fatal("bipc_send", rv);
-        }
-        return (rv);
-}
-
-int
-recv_name(bipc_socket_t sock, const char *name)
-{
-        char *buf = NULL;
-        int rv;
-        size_t sz;
-        if ((rv = bipc_recv(&sock, &buf, &sz)) == 0) {
-                printf("%s: RECEIVED \"%s\"\n", name, buf); 
-                nng_free(buf, sz);
-        }
-        return (rv);
-}
-
-int
-send_recv(bipc_socket_t sock, const char *name)
-{
-    int rv;
-    int timeout = 100;
-    // if ((rv = nng_setopt_ms(sock, NNG_OPT_RECVTIMEO, 100)) != 0) {
-    if ((rv = bipc_setopt(&sock, BIPC_OPT_RECVTIMEO, &timeout, sizeof(int))) != 0) {
-            fatal("nng_setopt_ms", rv);
-    }
-    for (;;) {
-            recv_name(sock, name);
-            sleep(1);
-            send_name(sock, name);
-    }
-}
-
-int
-node0(const char *url)
-{
-    bipc_socket_t sock;
-    int rv;
-    // if ((rv = nng_pair0_open(&sock)) != 0) {
-    //         fatal("nng_pair0_open", rv);
-    // }
-     if ((rv = bipc_listen(&sock, url, PAIR)) !=0) {
-            fatal("nng_listen", rv);
-    }
-    return (send_recv(sock, NODE0));
-}
-
-int
-node1(const char *url)
-{
-    bipc_socket_t sock;
-    int rv;
-    sleep(1);
-    // if ((rv = nng_pair0_open(&sock)) != 0) {
-    //         fatal("nng_pair0_open", rv);
-    // }
-    if ((rv = bipc_connect(&sock, url, PAIR)) != 0) {
-            fatal("nng_dial", rv);
-    }
-    return (send_recv(sock, NODE1));
-}
-
-int
-main(int argc, char **argv)
-{
-    if ((argc > 1) && (strcmp(NODE0, argv[1]) == 0))
-            return (node0(argv[2]));
-
-    if ((argc > 1) && (strcmp(NODE1, argv[1]) == 0))
-            return (node1(argv[2]));
-
-    fprintf(stderr, "Usage: pair %s|%s <URL> <ARG> ...\n", NODE0, NODE1);
-    return 1;
-}
\ No newline at end of file
diff --git a/bipc/test_pair.sh b/bipc/test_pair.sh
deleted file mode 100755
index 6238401..0000000
--- a/bipc/test_pair.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-./test_pair node0 ipc:///tmp/test_pair.ipc & node0=$!
-./test_pair node1 ipc:///tmp/test_pair.ipc & node1=$!
-sleep 4
-kill $node0 $node1
\ No newline at end of file
diff --git a/bipc/test_pubsub b/bipc/test_pubsub
deleted file mode 100755
index 19b5575..0000000
--- a/bipc/test_pubsub
+++ /dev/null
Binary files differ
diff --git a/bipc/test_pubsub.c b/bipc/test_pubsub.c
deleted file mode 100644
index 4f57719..0000000
--- a/bipc/test_pubsub.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include "bipc.h"
-
-#define SERVER "server"
-#define CLIENT "client"
-
-void
-fatal(const char *func, int rv)
-{
-        fprintf(stderr, "%s: %s\n", func, bipc_strerror(rv));
-}
-
-char *
-date(void)
-{
-        time_t now = time(&now);
-        struct tm *info = localtime(&now);
-        char *text = asctime(info);
-        text[strlen(text)-1] = '\0'; // remove '\n'
-        return (text);
-}
-
-int
-server(const char *url)
-{
-        bipc_socket_t sock;
-        int rv;
-
-        // if ((rv = nng_pub0_open(&sock)) != 0) {
-        //         fatal("nng_pub0_open", rv);
-        // }
-        if ((rv = bipc_listen(&sock, url, PUB_SUB)) < 0) {
-                fatal("nng_listen", rv);
-        }
-        for (;;) {
-                char *d = date();
-                printf("SERVER: PUBLISHING DATE %s\n", d);
-                if ((rv = bipc_send(&sock, d, strlen(d) + 1)) != 0) {
-                        fatal("nng_send", rv);
-                }
-                sleep(1);
-        }
-}
-
-int
-client(const char *url, const char *name)
-{
-        bipc_socket_t sock;
-        int rv;
-
-        // if ((rv = nng_sub0_open(&sock)) != 0) {
-        //         fatal("nng_sub0_open", rv);
-        // }
-
-        // // subscribe to everything (empty means all topics)
-        // if ((rv = nng_setopt(sock, NNG_OPT_SUB_SUBSCRIBE, "", 0)) != 0) {
-        //         fatal("nng_setopt", rv);
-        // }
-        if ((rv = bipc_connect(&sock, url, PUB_SUB)) != 0) {
-                fatal("nng_dial", rv);
-        }
-        for (;;) {
-                char *buf = NULL;
-                size_t sz;
-                if ((rv = bipc_recv(&sock, &buf, &sz)) != 0) {
-                        fatal("nng_recv", rv);
-                }
-                printf("CLIENT (%s): RECEIVED %s\n", name, buf); 
-                bipc_free(buf, sz);
-        }
-}
-
-int
-main(const int argc, const char **argv)
-{
-        if ((argc >= 2) && (strcmp(SERVER, argv[1]) == 0))
-                return (server(argv[2]));
-
-          if ((argc >= 3) && (strcmp(CLIENT, argv[1]) == 0))
-                return (client (argv[2], argv[3]));
-
-        fprintf(stderr, "Usage: pubsub %s|%s <URL> <ARG> ...\n",
-            SERVER, CLIENT);
-        return 1;
-}
\ No newline at end of file
diff --git a/bipc/test_pubsub.sh b/bipc/test_pubsub.sh
deleted file mode 100644
index ab8134c..0000000
--- a/bipc/test_pubsub.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-./test_pubsub server ipc:///tmp/test_pubsub.ipc & server=$! && sleep 1
-./test_pubsub client ipc:///tmp/test_pubsub.ipc client0 & client0=$!
-./test_pubsub client ipc:///tmp/test_pubsub.ipc client1 & client1=$!
-./test_pubsub client ipc:///tmp/test_pubsub.ipc client2 & client2=$!
-sleep 5
-kill $server $client0 $client1 $client2
\ No newline at end of file
diff --git a/bipc/test_pullpush b/bipc/test_pullpush
deleted file mode 100755
index c9ac05d..0000000
--- a/bipc/test_pullpush
+++ /dev/null
Binary files differ
diff --git a/bipc/test_pullpush.c b/bipc/test_pullpush.c
deleted file mode 100644
index f8e44ff..0000000
--- a/bipc/test_pullpush.c
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "bipc.h"
-
-#define NODE0 "node0"
-#define NODE1 "node1"
-
-void
-fatal(const char *func, int rv)
-{
-        fprintf(stderr, "%s: %s\n", func, bipc_strerror(rv));
-        exit(1);
-}
-
-int
-node0(const char *url)
-{
-        nng_socket sock;
-        int rv;
-
-        // if ((rv = nng_pull0_open(&sock)) != 0) {
-        //         fatal("nng_pull0_open", rv);
-        // }
-        if ((rv = bipc_listen(&sock, url, PULL_PUSH)) != 0) {
-                fatal("nng_listen", rv);
-        }
-        for (;;) {
-                char *buf = NULL;
-                size_t sz;
-                if ((rv = bipc_recv(&sock, &buf, &sz)) != 0) {
-                        fatal("nng_recv", rv);
-                }
-                printf("NODE0: RECEIVED \"%s\"\n", buf); 
-                bipc_free(buf, sz);
-        }
-}
-
-int
-node1(const char *url, char *msg)
-{
-        int sz_msg = strlen(msg) + 1; // '\0' too
-        nng_socket sock;
-        int rv;
-        int bytes;
-
-        // if ((rv = nng_push0_open(&sock)) != 0) {
-        //         fatal("nng_push0_open", rv);
-        // }
-        if ((rv = bipc_connect(&sock, url, PULL_PUSH)) != 0) {
-                fatal("nng_dial", rv);
-        }
-        printf("NODE1: SENDING \"%s\"\n", msg);
-        if ((rv = bipc_send(&sock, msg, strlen(msg)+1)) != 0) {
-                fatal("nng_send", rv);
-        }
-        sleep(1); // wait for messages to flush before shutting down
-        bipc_close(&sock);
-        return (0);
-}
-
-int
-main(int argc, char **argv)
-{
-        if ((argc > 1) && (strcmp(NODE0, argv[1]) == 0))
-                return (node0(argv[2]));
-
-        if ((argc > 2) && (strcmp(NODE1, argv[1]) == 0))
-                return (node1(argv[2], argv[3]));
-
-        fprintf(stderr, "Usage: pipeline %s|%s <URL> <ARG> ...'\n",
-                NODE0, NODE1);
-        return (1);
-}
\ No newline at end of file
diff --git a/bipc/test_pullpush.sh b/bipc/test_pullpush.sh
deleted file mode 100755
index 3b0c6a2..0000000
--- a/bipc/test_pullpush.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-./test_pullpush node0 ipc:///tmp/test_pullpush.ipc & node0=$! && sleep 1
-./test_pullpush node1 ipc:///tmp/test_pullpush.ipc "Hello, World!"
-./test_pullpush node1 ipc:///tmp/test_pullpush.ipc "Goodbye."
-kill $node0
\ No newline at end of file
diff --git a/bipc/test_reqrep b/bipc/test_reqrep
deleted file mode 100755
index 5ea08b5..0000000
--- a/bipc/test_reqrep
+++ /dev/null
Binary files differ
diff --git a/bipc/test_reqrep.c b/bipc/test_reqrep.c
deleted file mode 100644
index 0fe62e6..0000000
--- a/bipc/test_reqrep.c
+++ /dev/null
@@ -1,92 +0,0 @@
-#include "bipc.h"
-
-#define NODE0 "node0"
-#define NODE1 "node1"
-#define DATE "DATE"
-
-void
-fatal(const char *func, int rv)
-{
-    fprintf(stderr, "%s: %s\n", func, bipc_strerror(rv));
-    exit(1);
-}
-
-char *
-date(void)
-{
-    time_t now = time(&now);
-    struct tm *info = localtime(&now);
-    char *text = asctime(info);
-    text[strlen(text)-1] = '\0'; // remove '\n'
-    return (text);
-}
-
-int
-node0(const char *url)
-{
-    bipc_socket_t sock;
-    int rv;
-
-    // if ((rv = nng_rep0_open(&sock)) != 0) {
-    //         fatal("nng_rep0_open", rv);
-    // }
-    if ((rv = bipc_listen(&sock, url, REQ_REP)) != 0) {
-        fatal("nng_listen", rv);
-    }
-    for (;;) {
-        char *buf = NULL;
-        size_t sz;
-        if ((rv = bipc_recv(&sock, &buf, &sz)) != 0) {
-                fatal("nng_recv", rv);
-        }
-        if ((sz == (strlen(DATE) + 1)) && (strcmp(DATE, buf) == 0)) {
-            printf("NODE0: RECEIVED DATE REQUEST\n");
-            char *d = date();
-            printf("NODE0: SENDING DATE %s\n", d);
-            if ((rv = bipc_send(&sock, d, strlen(d) + 1)) != 0) {
-                    fatal("nng_send", rv);
-            }
-        }
-        bipc_free(buf, sz);
-    }
-}
-
-int
-node1(const char *url)
-{
-    bipc_socket_t sock;
-    int rv;
-    size_t sz;
-    char *buf = NULL;
-
-    // if ((rv = nng_req0_open(&sock)) != 0) {
-    //         fatal("bipc_socket_t", rv);
-    // }
-    if ((rv = bipc_connect(&sock, url, REQ_REP)) != 0) {
-            fatal("nng_dial", rv);
-    }
-    printf("NODE1: SENDING DATE REQUEST %s\n", DATE);
-    if ((rv = bipc_send(&sock, DATE, strlen(DATE)+1)) != 0) {
-            fatal("nng_send", rv);
-    }
-    if ((rv = bipc_recv(&sock, &buf, &sz)) != 0) {
-            fatal("nng_recv", rv);
-    }
-    printf("NODE1: RECEIVED DATE %s\n", buf);  
-    bipc_free(buf, sz);
-    bipc_close(&sock);
-    return (0);
-}
-
-int
-main(const int argc, const char **argv)
-{
-    if ((argc > 1) && (strcmp(NODE0, argv[1]) == 0))
-        return (node0(argv[2]));
-
-    if ((argc > 1) && (strcmp(NODE1, argv[1]) == 0))
-        return (node1(argv[2]));
-
-    fprintf(stderr, "Usage: reqrep %s|%s <URL> ...\n", NODE0, NODE1);
-    return (1);
-}
\ No newline at end of file
diff --git a/bipc/test_reqrep.sh b/bipc/test_reqrep.sh
deleted file mode 100755
index 54c3226..0000000
--- a/bipc/test_reqrep.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-./test_reqrep node0 ipc:///tmp/test_reqrep.ipc & node0=$! && sleep 1
-./test_reqrep node1 ipc:///tmp/test_reqrep.ipc
-kill $node0
\ No newline at end of file
diff --git a/bipc/test_survey b/bipc/test_survey
deleted file mode 100755
index 95a37dc..0000000
--- a/bipc/test_survey
+++ /dev/null
Binary files differ
diff --git a/bipc/test_survey.c b/bipc/test_survey.c
deleted file mode 100644
index b4ee7e7..0000000
--- a/bipc/test_survey.c
+++ /dev/null
@@ -1,96 +0,0 @@
-#include "bipc.h"
-
-#define SERVER "server"
-#define CLIENT "client"
-#define DATE   "DATE"
-
-
-
-void
-fatal(const char *func, int rv)
-{
-        fprintf(stderr, "%s: %s\n", func, bipc_strerror(rv));
-        exit(1);
-}
-
-char *
-date(void)
-{
-        time_t now = time(&now);
-        struct tm *info = localtime(&now);
-        char *text = asctime(info);
-        text[strlen(text)-1] = '\0'; // remove '\n'
-        return (text);
-}
-
-int
-server(const char *url)
-{
-    bipc_socket_t sock;
-    int rv;
-
-    
-    if ((rv = bipc_listen(&sock, url, SURVEY)) != 0) {
-        fatal("nng_listen", rv);
-    }
-    for (;;) {
-        printf("SERVER: SENDING DATE SURVEY REQUEST\n");
-        if ((rv = bipc_send(&sock, DATE, strlen(DATE) + 1)) != 0) {
-            fatal("nng_send", rv);
-        }
-
-        for (;;) {
-            char *buf = NULL;
-            size_t sz;
-            rv = bipc_recv(&sock, &buf, &sz);
-            if (rv == BIPC_ETIMEDOUT) {
-                break;
-            }
-            if (rv != 0) {
-                fatal("nng_recv", rv);
-            }
-            printf("SERVER: RECEIVED \"%s\" SURVEY RESPONSE\n", buf);
-            bipc_free(buf, sz);
-        }
-
-        printf("SERVER: SURVEY COMPLETE\n");
-    }
-}
-
-int
-client(const char *url, const char *name)
-{
-        bipc_socket_t sock;
-        int rv;
-         
-        if ((rv = bipc_connect(&sock, url, SURVEY)) != 0) {
-            fatal("nng_dial", rv);
-        }
-        for (;;) {
-            char *buf = NULL;
-            size_t sz;
-            if ((rv = bipc_recv(&sock, &buf, &sz)) == 0) {
-                printf("CLIENT (%s): RECEIVED \"%s\" SURVEY REQUEST, length=%d\n", name, buf, sz);
-                bipc_free(buf, sz);
-                char *d = date();
-                printf("CLIENT (%s): SENDING DATE SURVEY RESPONSE\n", name);
-                if ((rv = bipc_send(&sock, d, strlen(d) + 1)) != 0) {
-                    fatal("nng_send", rv);
-                }
-            }
-        }
-}
-
-int
-main(const int argc, const char **argv)
-{
-    if ((argc >= 2) && (strcmp(SERVER, argv[1]) == 0))
-        return (server(argv[2]));
-
-    if ((argc >= 3) && (strcmp(CLIENT, argv[1]) == 0))
-        return (client(argv[2], argv[3]));
-
-    fprintf(stderr, "Usage: survey %s|%s <URL> <ARG> ...\n",
-        SERVER, CLIENT);
-    return 1;
-}
\ No newline at end of file
diff --git a/bipc/test_survey.sh b/bipc/test_survey.sh
deleted file mode 100755
index 58358c4..0000000
--- a/bipc/test_survey.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-./test_survey server ipc:///tmp/test_survey.ipc & server=$!
-./test_survey client ipc:///tmp/test_survey.ipc client0 & client0=$!
-./test_survey client ipc:///tmp/test_survey.ipc client1 & client1=$!
-./test_survey client ipc:///tmp/test_survey.ipc client2 & client2=$!
-sleep 3 
-kill $server $client0 $client1 $client2
\ No newline at end of file
diff --git a/bipc/test_survey2 b/bipc/test_survey2
deleted file mode 100755
index b5439a7..0000000
--- a/bipc/test_survey2
+++ /dev/null
Binary files differ
diff --git a/bipc/test_survey2.c b/bipc/test_survey2.c
deleted file mode 100644
index 7c142a2..0000000
--- a/bipc/test_survey2.c
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <nng/nng.h>
-#include <nng/protocol/survey0/survey.h>
-#include <nng/protocol/survey0/respond.h>
-
-#define SERVER "server"
-#define CLIENT "client"
-char * DATE  = "DATE";
-
-void
-fatal(const char *func, int rv)
-{
-        fprintf(stderr, "%s: %s\n", func, nng_strerror(rv));
-        exit(1);
-}
-
-char *
-date(void)
-{
-        time_t now = time(&now);
-        struct tm *info = localtime(&now);
-        char *text = asctime(info);
-        text[strlen(text)-1] = '\0'; // remove '\n'
-        return (text);
-}
-
-int
-server(const char *url)
-{
-        nng_socket sock;
-        int rv;
-
-        if ((rv = nng_surveyor0_open(&sock)) != 0) {
-                fatal("nng_surveyor0_open", rv);
-        }
-        if ((rv = nng_listen(sock, url, NULL, 0)) != 0) {
-                fatal("nng_listen", rv);
-        }
-        for (;;) {
-                printf("SERVER: SENDING DATE SURVEY REQUEST\n");
-                if ((rv = nng_send(sock, DATE, strlen(DATE) + 1, 0)) != 0) {
-                        fatal("nng_send", rv);
-                }
-
-                for (;;) {
-                        char *buf = NULL;
-                        size_t sz;
-                        rv = nng_recv(sock, &buf, &sz, NNG_FLAG_ALLOC);
-                        if (rv == NNG_ETIMEDOUT) {
-                                break;
-                        }
-                        if (rv != 0) {
-                                fatal("nng_recv", rv);
-                        }
-                        printf("SERVER: RECEIVED \"%s\" SURVEY RESPONSE\n",
-                            buf); 
-                        nng_free(buf, sz);
-                }
-
-                printf("SERVER: SURVEY COMPLETE\n");
-        }
-}
-
-int
-client(const char *url, const char *name)
-{
-        nng_socket sock;
-        int rv;
-
-        if ((rv = nng_respondent0_open(&sock)) != 0) {
-                fatal("nng_respondent0_open", rv);
-        }
-        if ((rv = nng_dial(sock, url, NULL, NNG_FLAG_NONBLOCK)) != 0) {
-                fatal("nng_dial", rv);
-        }
-        for (;;) {
-                char *buf = NULL;
-                //char buf[1024];
-                size_t sz;
-                if ((rv = nng_recv(sock, &buf, &sz, NNG_FLAG_ALLOC)) == 0) {
-               // if ((rv = nng_recv(sock, buf, &sz, 0)) == 0) {
-                        printf("CLIENT (%s): RECEIVED \"%s\" SURVEY REQUEST\n",
-                            name, buf); 
-                       // nng_free(buf, sz);
-                        char *d = date();
-                        printf("CLIENT (%s): SENDING DATE SURVEY RESPONSE\n",
-                           name);
-                        if ((rv = nng_send(sock, d, strlen(d) + 1, 0)) != 0) {
-                                fatal("nng_send", rv);
-                        }
-                }
-        }
-}
-
-int
-main(const int argc, const char **argv)
-{
-        if ((argc >= 2) && (strcmp(SERVER, argv[1]) == 0))
-                return (server(argv[2]));
-
-        if ((argc >= 3) && (strcmp(CLIENT, argv[1]) == 0))
-                return (client(argv[2], argv[3]));
-
-        fprintf(stderr, "Usage: survey %s|%s <URL> <ARG> ...\n",
-            SERVER, CLIENT);
-        return 1;
-}
\ No newline at end of file
diff --git a/bipc/test_survey2.sh b/bipc/test_survey2.sh
deleted file mode 100755
index 618d19f..0000000
--- a/bipc/test_survey2.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-./test_survey2 server ipc:///tmp/test_survey2.ipc & server=$!
-./test_survey2 client ipc:///tmp/test_survey2.ipc client0 & client0=$!
-./test_survey2 client ipc:///tmp/test_survey2.ipc client1 & client1=$!
-./test_survey2 client ipc:///tmp/test_survey2.ipc client2 & client2=$!
-sleep 3 
-kill $server $client0 $client1 $client2
\ No newline at end of file
diff --git a/common/Makefile b/common/Makefile
index 7b626f7..f8e0188 100755
--- a/common/Makefile
+++ b/common/Makefile
@@ -12,8 +12,9 @@
 SOURCES := $(wildcard *.c)
 OBJS   = $(patsubst %.c, %.o, $(SOURCES)) 
 
+all: libs
 
-all: $(LIBCOMMON) $(DLIBCOMMON)
+libs: $(LIBCOMMON) $(DLIBCOMMON)
 
 
 #static lib
@@ -26,6 +27,7 @@
 	rm -f *.o
 	$(CC) -fPIC -shared $(CFLAGS) $^ -o $@ $(LDFLAGS)
 
+
 #PREFIX is environment variable, but if it is not set, then set default value
 ifeq ($(PREFIX),)
     PREFIX := /usr/local
diff --git a/common/libusgcommon.a b/common/libusgcommon.a
index c87dc00..8a75a4e 100644
--- a/common/libusgcommon.a
+++ b/common/libusgcommon.a
Binary files differ
diff --git a/common/libusgcommon.so b/common/libusgcommon.so
index d5abb78..c11f6c2 100755
--- a/common/libusgcommon.so
+++ b/common/libusgcommon.so
Binary files differ
diff --git a/service/netdisk_service b/service/netdisk_service
index 51ffa2d..fd9bbc1 100755
--- a/service/netdisk_service
+++ b/service/netdisk_service
Binary files differ
diff --git a/service/test b/service/test
index a32becf..f5f368d 100755
--- a/service/test
+++ b/service/test
Binary files differ
diff --git a/service/test_client b/service/test_client
index bf86e07..baf8670 100755
--- a/service/test_client
+++ b/service/test_client
Binary files differ
diff --git a/service/test_properties b/service/test_properties
index 335c825..31584af 100755
--- a/service/test_properties
+++ b/service/test_properties
Binary files differ
diff --git a/service/test_queue b/service/test_queue
index 9989048..e417957 100755
--- a/service/test_queue
+++ b/service/test_queue
Binary files differ

--
Gitblit v1.8.0