File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 3434#include "log.h"
3535#include "table_stdio.h"
3636
37+ #define REPLYBUFFERSIZE 100000
38+
3739static char * config ;
3840static int sock = -1 ;
41+ static int connected = 0 ;
3942static FILE * sockstream ;
40- #define REPLYBUFFERSIZE 100000
4143static char repbuffer [REPLYBUFFERSIZE + 1 ];
4244
4345enum socketmap_reply {
@@ -76,6 +78,8 @@ table_socketmap_connect(const char *s)
7678 goto err ;
7779 }
7880
81+ connected = 1 ;
82+
7983 return 1 ;
8084
8185err :
@@ -94,6 +98,13 @@ table_socketmap_query(const char *name, const char *key)
9498 ssize_t len ;
9599 int ret = SM_PERM ;
96100
101+ if (!connected ) {
102+ if (!table_socketmap_connect (config )) {
103+ log_warnx ("error connecting to %s" , config );
104+ return ret ;
105+ }
106+ }
107+
97108 memset (repbuffer , 0 , sizeof repbuffer );
98109 fprintf (sockstream , "%s %s\n" , name , key );
99110 fflush (sockstream );
@@ -224,9 +235,6 @@ main(int argc, char **argv)
224235
225236 config = argv [0 ];
226237
227- if (table_socketmap_connect (config ) == 0 )
228- fatalx ("error connecting to %s" , config );
229-
230238 table_api_on_update (table_socketmap_update );
231239 table_api_on_check (table_socketmap_check );
232240 table_api_on_lookup (table_socketmap_lookup );
You can’t perform that action at this time.
0 commit comments