[Getdata-commits] SF.net SVN: getdata:[842] trunk/defile
Scientific Database Format
Brought to you by:
ketiltrout
|
From: <ket...@us...> - 2013-07-27 12:20:41
|
Revision: 842
http://sourceforge.net/p/getdata/code/842
Author: ketiltrout
Date: 2013-07-27 12:20:38 +0000 (Sat, 27 Jul 2013)
Log Message:
-----------
Fix server-side df_reinit.
Modified Paths:
--------------
trunk/defile/bin/net.c
trunk/defile/lib/internal.h
trunk/defile/lib/libdefile.c
Modified: trunk/defile/bin/net.c
===================================================================
--- trunk/defile/bin/net.c 2013-07-25 10:55:55 UTC (rev 841)
+++ trunk/defile/bin/net.c 2013-07-27 12:20:38 UTC (rev 842)
@@ -1037,6 +1037,25 @@
}
}
break;
+ case DF_RPC_HELLO:
+ /* an extra hello, probably due to a reinit, just get and discard the
+ * whole thing */
+ switch (pos) {
+ case 0:
+ string[0] = malloc(DF_HELLO_LEN);
+ if (string[0] == NULL) {
+ DF_OOM(DF_PRN_DF);
+ exit(1);
+ }
+ framepos = 0;
+ pos++;
+ case 1:
+ DF_GET_DATA(0, GD_UINT8, DF_HELLO_LEN - 1);
+ case 2:
+ free(string[0]);
+ rpc = -1;
+ }
+ break;
default:
df_dprintf(DF_PRN_ERR, "unhandled rpc from server: %02x\n",
(unsigned int)rpc);
Modified: trunk/defile/lib/internal.h
===================================================================
--- trunk/defile/lib/internal.h 2013-07-25 10:55:55 UTC (rev 841)
+++ trunk/defile/lib/internal.h 2013-07-27 12:20:38 UTC (rev 842)
@@ -119,8 +119,8 @@
#define DF_RPC_HELLO 0xFF
/* the server salutation */
-#define DF_HELLO {DF_RPC_HELLO, 0x0A, 'D', 'E', 'F', 'I', 'L', 'E', 0x0D, 0x0A, DF_SRV_SEX, DF_RPC_VERSION, \
- DF_RPC_REVISION}
+#define DF_HELLO {DF_RPC_HELLO, 0x0A, 'D', 'E', 'F', 'I', 'L', 'E', 0x0D, \
+ 0x0A, DF_SRV_SEX, DF_RPC_VERSION, DF_RPC_REVISION}
#define DF_HELLO_LEN 13
/* private mode flags */
@@ -302,6 +302,7 @@
struct df_rpc *srv_slug;
int srv_nslug;
pthread_mutex_t srv_mx;
+ int srv_ind;
int nfd;
struct df_infdef *fd;
Modified: trunk/defile/lib/libdefile.c
===================================================================
--- trunk/defile/lib/libdefile.c 2013-07-25 10:55:55 UTC (rev 841)
+++ trunk/defile/lib/libdefile.c 2013-07-27 12:20:38 UTC (rev 842)
@@ -107,7 +107,7 @@
return df_rc_shell_expand(DF_PRN_INPUT, argument);
}
-/* Push a RPC ont a slug */
+/* Push a RPC onto a slug */
static int df_rpc_vpush(struct df_rpc *slug, uint8_t rpc, va_list ap)
{
const struct df_fdef *fd;
@@ -1039,10 +1039,10 @@
usleep(10000);
}
-static int df_init_server(long long length, double rate, const char *name,
- int hello)
+static int df_init_server(long long length, double rate, const char *name)
{
if (df->mode_flags & DF_MODE_SERVER) {
+ df->srv_ind = 0;
df->srv_nslug = 1;
df->srv_slug = (struct df_rpc *)malloc(sizeof(struct df_rpc));
@@ -1050,7 +1050,7 @@
return DF_OUTPUT;
/* server salutation */
- if (hello && df_rpc_push(df->srv_slug, DF_RPC_HELLO))
+ if (df_rpc_push(df->srv_slug, DF_RPC_HELLO))
return DF_OUTPUT;
if (df_rpc_push(df->srv_slug, DF_RPC_INIT, length, rate, name ? name :
@@ -1109,7 +1109,7 @@
}
/* good to go -- do the server initialisation, if necessary */
- return df_init_server(length, rate, name, 1);
+ return df_init_server(length, rate, name);
}
const char *df_input_name(int shell_expand)
@@ -1501,7 +1501,7 @@
pthread_mutex_unlock(&df_rate_mx);
/* good to go -- do the server initialisation, if necessary */
- return df_init_server(length, rate, name, 0);
+ return df_init_server(length, rate, name);
}
df_abort_func_t df_on_abort(df_abort_func_t abort_func) {
@@ -2037,7 +2037,6 @@
int df_add_fragment(const char *name, int parent, unsigned long encoding,
unsigned long byte_sex, const char *prefix, const char *suffix)
{
- static int srv_ind = 0;
const int append = df_mode() & DF_MODE_APPEND;
int ind;
char *path, *ptr;
@@ -2049,7 +2048,7 @@
encoding, byte_sex, prefix, suffix);
if (ind)
return ind;
- return ++srv_ind; /* a fake fragment index */
+ return ++df->srv_ind; /* a fake fragment index */
}
/* make the containing directory */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|