X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=nfs3%2Frpc.c;h=465bcd388e292b6bf3adae978c3c4a3c6280ef53;hb=105feb97ef2173d6ea45df177599be6d4592640b;hp=07c5d93e7a0cfd4c1a195ee0cbc9ca518f8ca1bc;hpb=50c08ba526a6638e8e3c4eec0503365a2c110a85;p=bluesky.git diff --git a/nfs3/rpc.c b/nfs3/rpc.c index 07c5d93..465bcd3 100644 --- a/nfs3/rpc.c +++ b/nfs3/rpc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -121,68 +122,6 @@ struct rpc_fail_reply { uint32_t accept_stat; }; -/* Routines for XDR-encoding to a growable string. */ -static bool_t xdr_string_putlong(XDR *xdrs, const long *lp) -{ - GString *str = (GString *)xdrs->x_private; - uint32_t data = htonl(*lp); - g_string_set_size(str, str->len + 4); - memcpy(str->str + str->len - 4, &data, 4); - return TRUE; -} - -static bool_t xdr_string_putbytes(XDR *xdrs, const char *addr, u_int len) -{ - GString *str = (GString *)xdrs->x_private; - g_string_set_size(str, str->len + len); - memcpy(str->str + str->len - len, addr, len); - return TRUE; -} - -static u_int xdr_string_getpos(const XDR *xdrs) -{ - GString *str = (GString *)xdrs->x_private; - return str->len; -} - -static bool_t xdr_string_putint32(XDR *xdrs, const int32_t *ip) -{ - GString *str = (GString *)xdrs->x_private; - uint32_t data = htonl(*ip); - g_string_set_size(str, str->len + 4); - memcpy(str->str + str->len - 4, &data, 4); - return TRUE; -} - -static int32_t *xdr_string_inline(XDR *xdrs, u_int len) -{ - GString *str = (GString *)xdrs->x_private; - g_string_set_size(str, str->len + len); - return (int32_t *)(str->str + str->len - len); -} - -static void xdr_string_destroy(XDR *xdrs) -{ -} - -static struct xdr_ops xdr_string_ops = { - .x_putlong = xdr_string_putlong, - .x_putbytes = xdr_string_putbytes, - .x_getpostn = xdr_string_getpos, - .x_putint32 = xdr_string_putint32, - .x_inline = xdr_string_inline, - .x_destroy = xdr_string_destroy, -}; - -static void xdr_string_create(XDR *xdrs, GString *string, enum xdr_op op) -{ - xdrs->x_op = op; - xdrs->x_ops = &xdr_string_ops; - xdrs->x_private = (char *)string; - xdrs->x_base = NULL; - xdrs->x_handy = 0; -} - static void async_rpc_send_failure(RPCRequest *req, enum accept_stat stat) { @@ -209,6 +148,7 @@ async_rpc_send_failure(RPCRequest *req, enum accept_stat stat) if (!req->xdr_args_free(&xdr, req->args)) { fprintf(stderr, "unable to free arguments"); } + g_free(req->args); } if (req->raw_args != NULL) @@ -270,6 +210,7 @@ async_rpc_send_reply(RPCRequest *req, void *result) if (!req->xdr_args_free(&xdr, req->args)) { fprintf(stderr, "unable to free arguments"); } + g_free(req->args); } if (req->raw_args != NULL) @@ -505,8 +446,6 @@ nfs_program_3(RPCRequest *req) req->xdr_result = _xdr_result; result = (*local)((char *)req->args, req); - bluesky_debug_dump(fs); - return; } @@ -518,8 +457,22 @@ static GMainLoop *main_loop; static GThreadPool *rpc_thread_pool; +static volatile int fs_dump_requested = 0; + +static void sig_handler(int sig) +{ + if (sig == SIGUSR1) { + fs_dump_requested = 1; + } +} + static gboolean async_flushd(gpointer data) { + if (fs_dump_requested) { + bluesky_debug_dump(fs); + fs_dump_requested = 0; + } + bluesky_flushd_invoke(fs); return TRUE; } @@ -541,6 +494,15 @@ static async_rpc_init() g_source_set_callback(source, async_flushd, NULL, NULL); g_source_attach(source, main_context); g_source_unref(source); + + /* Signal USR1 is used to request a debugging dump of filesyste info */ + struct sigaction sa; + sa.sa_handler = sig_handler; + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART; + if (sigaction(SIGUSR1, &sa, NULL) < 0) { + perror("sigaction"); + } } struct rpc_call_header { @@ -622,7 +584,11 @@ static gboolean async_rpc_dispatch(RPCConnection *rpc) req->req_proc = ntohl(header->proc); rpc->msgbuf = g_string_new(""); - g_thread_pool_push(rpc_thread_pool, req, NULL); + if (bluesky_options.sync_frontends) { + nfs_program_3(req); + } else { + g_thread_pool_push(rpc_thread_pool, req, NULL); + } return TRUE; }