Changeset: 9f0de6bebf13 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9f0de6bebf13
Modified Files:
monetdb5/modules/mal/remote.c
monetdb5/modules/mal/remote.h
monetdb5/modules/mal/remote.mal
monetdb5/scheduler/run_octopus.c
Branch: default
Log Message:
remote: add isalive function, and fix disconnect
Add isalive function to check if the connection is still up.
Fix signature of RMTdisconnect after Martin's debugging additions to
work with MAL. It's a bit of a hack, admittedly.
diffs (93 lines):
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -279,7 +279,7 @@ str RMTconnect(
* system, it only needs to exist for the client (i.e. it was once
* created).
*/
-str RMTdisconnect(Client cntxt, int *ret, str *conn) {
+str RMTdisconnect(Client cntxt, str *conn) {
connection c, t;
if (conn == NULL || *conn == NULL || strcmp(*conn, (str)str_nil) == 0)
@@ -287,8 +287,7 @@ str RMTdisconnect(Client cntxt, int *ret
"is NULL or nil");
- /* just make sure the return isn't garbage */
- *ret = 0;
+ /* The return is obfuscated by the debug cntxt argument */
#ifdef _DEBUG_REMOTE
mnstr_printf(cntxt->fdout, "#disconnect link %s\n", *conn);
#else
@@ -1349,3 +1348,27 @@ str RMTbintype(Client cntxt, MalBlkPtr m
return(MAL_SUCCEED);
}
+/**
+ * Returns whether the underlying connection is still connected or not.
+ * Best effort implementation on top of mapi using a ping.
+ */
+str
+RMTisalive(int *ret, str *conn)
+{
+ str tmp;
+ connection c;
+
+ (void)mb;
+
+ if (conn == NULL || strcmp(conn, (str)str_nil) == 0)
+ throw(ILLARG, "remote.get", ILLEGAL_ARGUMENT ": connection name
is NULL or nil");
+
+ /* lookup conn, set c if valid */
+ rethrow("remote.get", tmp, RMTfindconn(&c, conn));
+
+ *ret = 0;
+ if (mapi_is_connected(conn->mconn) != 0 && mapi_ping(conn->mconn) ==
MOK)
+ *ret = 1;
+
+ return MAL_SUCCEED;
+}
diff --git a/monetdb5/modules/mal/remote.h b/monetdb5/modules/mal/remote.h
--- a/monetdb5/modules/mal/remote.h
+++ b/monetdb5/modules/mal/remote.h
@@ -49,7 +49,7 @@ remote_export str RMTconnect(
str *uri,
str *user,
str *passwd);
-remote_export str RMTdisconnect(Client cntxt, int *ret, str *conn);
+remote_export str RMTdisconnect(Client cntxt, str *conn);
remote_export str RMTget(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
remote_export str RMTput(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
remote_export str RMTregisterInternal(Client cntxt, str conn, str mod, str
fcn);
@@ -59,4 +59,5 @@ remote_export str RMTbatload(Client cntx
remote_export str RMTbincopyto(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
remote_export str RMTbincopyfrom(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
remote_export str RMTbintype(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
+remote_export str RMTisalive(int *ret, str *conn);
#endif /* _REMOTE_DEF */
diff --git a/monetdb5/modules/mal/remote.mal b/monetdb5/modules/mal/remote.mal
--- a/monetdb5/modules/mal/remote.mal
+++ b/monetdb5/modules/mal/remote.mal
@@ -75,6 +75,9 @@ comment "remotely executes <mod>.<func>
pattern exec(conn:str, mod:str, func:str, :str...):str...
address RMTexec
comment "remotely executes <mod>.<func> using the argument list of remote
objects and returns the handle to its result";
+command isalive(conn:str):int
+address RMTisalive
+comment "check if conn is still valid and connected";
# helper functions not primilarily intended for normal use
diff --git a/monetdb5/scheduler/run_octopus.c b/monetdb5/scheduler/run_octopus.c
--- a/monetdb5/scheduler/run_octopus.c
+++ b/monetdb5/scheduler/run_octopus.c
@@ -644,7 +644,7 @@ OCTOPUSdisconnect(Client cntxt)
for ( i=0; i< nrpeers; i++)
if ( peers[i].active && peers[i].conn != NULL ) {
- msg = RMTdisconnect(cntxt,&ret,&peers[i].conn);
+ msg = RMTdisconnect(cntxt,&peers[i].conn);
GDKfree(peers[i].conn);
peers[i].conn = NULL;
}
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list