Update of /cvsroot/monetdb/pathfinder/runtime
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv12882/runtime
Modified Files:
pathfinder.mx shttpd.c shttpd.h xrpc_client.mx xrpc_server.mx
Log Message:
propagated changes of Wednesday Feb 21 2007 - Thursday Feb 22 2007
from the XQuery_0-16 branch to the development trunk
Index: xrpc_client.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/xrpc_client.mx,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- xrpc_client.mx 20 Feb 2007 12:07:02 -0000 1.11
+++ xrpc_client.mx 22 Feb 2007 11:34:46 -0000 1.12
@@ -375,8 +375,8 @@
# where executions might have succeeded, so we only print a
# WARNING by error, iso. terminate the execution with 'ERROR'
printf("!WARNING: doLoopLiftedRPC: ");
- printf("error occurred during RPC call to \"%s\".\n", $t);
- printf("!WARNING: Received error was: \n%s\n", rpc_err);
+ printf("error occurred during RPC call to \"%s\"\n%s\n",
+ $t, rpc_err);
}
var time_milClntDeSeriaEnd := usec();
@@ -538,9 +538,9 @@
struct in_addr addr;
struct sockaddr_in sockaddr;
struct hostent *resolv = NULL;
- int i, ret, sock, port = HTTPD_DEFAULT_PORT;
+ int i, ret, sock, port = 0;
str strptr = NULL;
-
+
errno = 0;
/* 'dst' has the form 'URL[:port]' */
@@ -552,6 +552,16 @@
strerror(errno));
return -1;
}
+ } else { /* find the default port number from "monet_environment" */
+ if( !(strptr = GDKgetenv("xrpc_port")) || !(*strptr) ){
+ if( !(strptr = GDKgetenv("mapi_port")) ){
+ GDKerror("setup_connection: could not find \"mapi_port\"\n");
+ return -1;
+ }
+ port = atoi(strptr) + 1;
+ } else {
+ port = atoi(strptr);
+ }
}
if (isdigit((int)dst[0])) {
@@ -1036,7 +1046,7 @@
"Content-Type: text/html; charset=\"utf-8\"\r\n"
"Content-Length: " SZFMT "\r\n\r\n"
"%s",
- HTTPD_FUNC, dst, b->pos, b->buf);
+ XRPCD_CALLBACK, dst, b->pos, b->buf);
if (bytes_sent < b->pos) {
GDKerror("CMDhttp_post: failed to send XRPC request.");
clean_up(sock, in, out, bs, b, argcnt, iterc);
@@ -1068,10 +1078,33 @@
/* the HTTP header starts with "HTTP/1.x xxx", after the first
* white space character, it is the 3-digits return code */
strptr = strchr(b->buf, (int)' ') + 1;
- if (!strptr || (strstr(strptr, "200") != strptr) ||
- (strptr = strstr(strptr, "<env:Fault")) ) {
- GDKerror("CMDhttp_post: remote execution failed\n");
- GDKerror("%s\n", strptr?strptr:b->buf);
+ if (!strptr ||
+ (strstr(strptr, "200") != strptr) ||
+ strstr(strptr, "<env:Fault") ) {
+
+ /* get the error code, error string out of the message */
+ if(strptr){
+ char *ptr = strchr(strptr, '\r');
+ if (ptr){
+ ptr[0] = '\0';
+ GDKerror("HTTP Error Code : %s\n", b->buf);
+ strptr = strstr(ptr+1, "<env:Fault");
+ if(strptr){
+ strptr = strstr(strptr, "<env:Value>") + 11;
+ ptr = strchr(strptr, '<');
+ ptr[0] = '\0';
+ GDKerror("SOAP Fault Code : %s\n", strptr);
+ strptr = strstr(ptr+1, "<env:Text") + 10;
+ strptr = strchr(strptr, '>') + 1;
+ ptr = strchr(strptr, '<');
+ ptr[0] = '\0';
+ GDKerror("SOAP Fault Reason: %s\n", strptr);
+ }
+ }
+ } else {
+ GDKerror("CMDhttp_post: remote execution failed, "
+ "no further information can be provided\n");
+ }
clean_up(sock, in, out, bs, b, argcnt, iterc);
return GDK_FAIL;
}
Index: shttpd.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/shttpd.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- shttpd.c 20 Feb 2007 12:07:01 -0000 1.20
+++ shttpd.c 22 Feb 2007 11:34:46 -0000 1.21
@@ -332,11 +332,11 @@
* change enum that goes below!
*/
{'d', "document_root", 0, NULL, OPT_STR, {0}, NULL },
- {'i', "index_files", 0, NULL, OPT_STR, {0}, INDEX_FILES },
- {'D', "list_directories",0,NULL, OPT_BOOL, {0}, "1" },
- {'c', "cgi_extention", 0, NULL, OPT_STR, {0}, CGI_EXTENTION },
- {'N', "server_name", 0, NULL, OPT_STR, {0}, AUTH_REALM },
- {'p', "listen_port", 0, NULL, OPT_INT, {0}, LISTEN_PORT },
+ {'i', "index_files", 1, NULL, OPT_STR, {INDEX_FILES}, INDEX_FILES
},
+ {'D', "list_directories",1,NULL, OPT_BOOL, {0}, "0" },
+ {'c', "cgi_extention", 1, NULL, OPT_STR, {CGI_EXTENTION},
CGI_EXTENTION },
+ {'N', "server_name", 1, NULL, OPT_STR, {AUTH_REALM}, AUTH_REALM
},
+ {'p', "listen_port", 1, NULL, OPT_INT, {LISTEN_PORT}, LISTEN_PORT
},
{'l', "access_log", 0, NULL, OPT_STR, {0}, NULL },
{'e', "error_log", 0, NULL, OPT_STR, {0}, NULL },
{'m', "mime_types", 0, NULL, OPT_STR, {0}, NULL },
@@ -346,7 +346,7 @@
{'I', "inetd_mode", 0, NULL, OPT_BOOL, {0}, "0" },
{'u', "runtime_uid", 0, NULL, OPT_STR, {0}, NULL },
{'V', "show_stats", 0, NULL, OPT_BOOL, {0}, "0" },
- {'C', "config_file", 0, NULL, OPT_STR, {0}, CONFIG },
+ {'C', "config_file", 1, NULL, OPT_STR, {CONFIG}, CONFIG
},
{0, NULL, 0, NULL, OPT_BOOL, {0}, NULL }
};
@@ -1080,7 +1080,7 @@
* Setup listening socket on given port, return socket
*/
shttpd_socket
-shttpd_open_port(int port)
+shttpd_open_port(int port, int accept_any)
{
shttpd_socket ret;
SOCKET sock;
@@ -1092,10 +1092,10 @@
if (port == 0)
port = INTOPT(OPT_LISTENPORT);
- sa.len = sizeof(sa.u.sin);
- sa.u.sin.sin_family = AF_INET;
- sa.u.sin.sin_port = htons((uint16_t) port);
- sa.u.sin.sin_addr.s_addr = htonl(INADDR_ANY);
+ sa.len = sizeof(sa.u.sin);
+ sa.u.sin.sin_family = AF_INET;
+ sa.u.sin.sin_port = htons((uint16_t) port);
+ sa.u.sin.sin_addr.s_addr =
accept_any?htonl(INADDR_ANY):htonl(INADDR_LOOPBACK);
if ((sock = socket(PF_INET, SOCK_STREAM, 6)) == -1)
elog(ERR_FATAL, "shttpd_open_port: socket: %s",strerror(ERRNO));
@@ -3108,8 +3108,6 @@
/* Free configuration */
for (opt = options; opt->sw != 0; opt++) {
- if (opt->type == OPT_STR && opt->value.value_str != NULL)
- free(opt->value.value_str);
opt->set = 0;
opt->value.value_str = NULL;
}
@@ -3242,6 +3240,12 @@
return arg->connection->uri;
}
+struct in_addr
+shttpd_get_inAddr(struct shttpd_callback_arg *arg)
+{
+ return arg->connection->sa.u.sin.sin_addr;
+}
+
void
shttpd_finish(struct shttpd_callback_arg *arg)
{
Index: shttpd.h
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/shttpd.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- shttpd.h 20 Feb 2007 12:07:02 -0000 1.7
+++ shttpd.h 22 Feb 2007 11:34:46 -0000 1.8
@@ -159,7 +159,7 @@
extern void shttpd_setopt(const char *variable, const char *value);
extern void shttpd_addmimetype(const char *ext, const char *mime);
extern void shttpd_register_mountpoint(const char *uri, const char
*system_path);
-extern shttpd_socket shttpd_open_port(int port);
+extern shttpd_socket shttpd_open_port(int port, int accept_any);
extern void shttpd_register_url(const char *url,
shttpd_callback_t callback, void
*callback_data);
extern void shttpd_protect_url(const char *url, const char *file);
@@ -172,6 +172,7 @@
extern char *shttpd_get_method(struct shttpd_callback_arg *arg);
extern char *shttpd_get_uri(struct shttpd_callback_arg *arg);
extern int shttpd_get_socket(struct shttpd_callback_arg *arg);
+extern struct in_addr shttpd_get_inAddr(struct shttpd_callback_arg *arg);
extern void shttpd_finish(struct shttpd_callback_arg *arg);
#ifdef MT
Index: xrpc_server.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/xrpc_server.mx,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- xrpc_server.mx 20 Feb 2007 12:07:02 -0000 1.12
+++ xrpc_server.mx 22 Feb 2007 11:34:46 -0000 1.13
@@ -40,61 +40,123 @@
@- HTTP server function(s)
@m
-.COMMAND httpd_start(int port, str option) : void = CMDhttpd_start;
+.COMMAND rpcd_start(int port, bit open, str options) : void = CMDrpcd_start;
"Start the HTTP server for RPC calls on the specified port."
.EPILOGUE = xrpc_epilogue;
.END xrpc_server;
@mil
[...1117 lines suppressed...]
/* Open listening socket */
- ctx = shttpd_open_port(*port);
+ ctx = shttpd_open_port(xrpc_port, *open);
+ listen_socket = ctx.sock;
/* Serve connections infinitely until someone kills us */
for ( ; rpcd_running; ) shttpd_poll(&ctx, 200);
@@ -905,8 +1198,10 @@
return GDK_SUCCEED;
}
-void xrpc_epilogue() {
+void xrpc_epilogue()
+{
shttpd_fini(); /* Shut down the HTTP server. */
rpcd_running = 0; /* Stop RPC server */
+ close(listen_socket);
}
/* vim:set shiftwidth=4 expandtab: */
Index: pathfinder.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/pathfinder.mx,v
retrieving revision 1.296
retrieving revision 1.297
diff -u -d -r1.296 -r1.297
--- pathfinder.mx 20 Feb 2007 12:07:00 -0000 1.296
+++ pathfinder.mx 22 Feb 2007 11:34:44 -0000 1.297
@@ -2710,31 +2710,43 @@
}
# fn:collections(), get all collection *names*
-PROC ws_collections(BAT[void,BAT] ws) : BAT[void,oid]
+PROC ws_collections(BAT[void,BAT] ws, bit consistent) : BAT[void,oid]
{
var coll_nme, coll_sze, coll_mbs, coll_upd;
- pflock_meta(ws_id(ws)); # stop all concurrent shred_doc/del_doc activities
+ if (consistent) pflock_meta(ws_id(ws)); # stop all concurrent
shred_doc/del_doc activities
lock_set(pf_short);
var err := CATCH( { coll_nme :=
mirror(collection_name.[startsWith]("::").uselect(false));
- coll_sze :=
coll_nme.leftjoin(doc_collection.histogram()).tmark([EMAIL PROTECTED]).[str]();
+ coll_sze :=
doc_name.uselect(str_nil,str_nil).mirror().leftjoin(doc_collection).histogram();
+ coll_sze := coll_nme.leftjoin(coll_sze).tmark([EMAIL
PROTECTED]).[str]();
coll_mbs := [/](coll_nme.leftjoin(collection_size),
1024LL * 1024LL).tmark([EMAIL PROTECTED]).[str]().[+](" MB");
coll_upd :=
coll_nme.[lng]().[str]().[+]("_map_pid").[bat]().[int]().[ttype]().[=](oid).tmark([EMAIL
PROTECTED]).[str]();
- coll_nme :=
coll_nme.leftjoin(collection_name).tmark([EMAIL PROTECTED]); });
+ coll_nme :=
coll_nme.leftjoin(collection_name).tmark([EMAIL PROTECTED]);
+ if (not(consistent)) { # here we include info about
shredding in progress
+ var shred :=
mirror(colname_shredlock).[startsWith]("::").uselect(false).hmark([EMAIL
PROTECTED]);
+ var tmp := shred.tdiff(coll_nme); # new collection
names being shredded
+ coll_nme :=
coll_nme.copy().access(BAT_APPEND).append(tmp);
+ coll_upd :=
coll_upd.copy().access(BAT_APPEND).append(tmp := tmp.project("unknown"));
+ coll_mbs :=
coll_mbs.copy().access(BAT_APPEND).append(tmp);
+ coll_sze :=
coll_sze.copy().access(BAT_APPEND).append(tmp);
+ coll_upd := [+](coll_upd,
[isnil](coll_nme.outerjoin(reverse(shred))).[ifthenelse](""," (shredding..)"));
+ }});
lock_unset(pf_short);
if (not(isnil(err))) ERROR(err);
return xmltab4(ws, "collection", coll_nme, "numDocs", coll_sze, "size",
coll_mbs, "updatable", coll_upd);
}
# fn:documents(), get all document *names* in a collection
-PROC ws_documents(BAT[void,BAT] ws, BAT[any,str] coll_nme) : BAT[oid,oid]
+PROC ws_documents(BAT[void,BAT] ws, BAT[any,str] coll_nme, bit consistent) :
BAT[oid,oid]
{
var doc_nme, doc_col, doc_url, doc_upd;
- pflock_meta(ws_id(ws)); # stop all concurrent shred_doc/del_doc activities
+ if (consistent) pflock_meta(ws_id(ws)); # stop all concurrent
shred_doc/del_doc activities
lock_set(pf_short);
- var err := CATCH( { doc_nme :=
coll_nme.leftjoin(reverse(collection_name)).leftjoin(reverse(doc_collection));
+ var err := CATCH( { var col_upd :=
collection_name.mirror().[lng]().[str]().[+]("_map_pid").[bat]().[int]().[ttype]().[=](oid).tmark([EMAIL
PROTECTED]).[str]();
+ doc_nme :=
doc_name.uselect(str_nil,str_nil).mirror().leftjoin(doc_collection);
+ doc_nme :=
coll_nme.leftjoin(reverse(collection_name)).leftjoin(reverse(doc_nme));
doc_url := doc_nme.leftjoin(doc_location).tmark([EMAIL
PROTECTED]);
doc_col :=
doc_nme.leftjoin(doc_collection).tmark([EMAIL PROTECTED]);
- doc_upd :=
doc_col.[lng]().[str]().[+]("_map_pid").[bat]().[int]().[ttype]().[=](oid).tmark([EMAIL
PROTECTED]).[str]();
+ doc_upd := doc_col.leftjoin(col_upd).tmark([EMAIL
PROTECTED]);
doc_col :=
doc_col.leftjoin(collection_name).tmark([EMAIL PROTECTED]);
doc_nme := doc_nme.leftjoin(doc_name); });
lock_unset(pf_short);
@@ -2743,15 +2755,16 @@
}
# fn:documents(), get all document *names*
-PROC ws_documents(BAT[void,BAT] ws) : BAT[void,oid]
+PROC ws_documents(BAT[void,BAT] ws, bit consistent) : BAT[void,oid]
{
var doc_nme, doc_col, doc_url, doc_upd;
- pflock_meta(ws_id(ws)); # stop all concurrent shred_doc/del_doc activities
+ if (consistent) pflock_meta(ws_id(ws)); # stop all concurrent
shred_doc/del_doc activities
lock_set(pf_short);
- var err := CATCH( { doc_nme :=
mirror(doc_name.[startsWith]("::").uselect(false));
+ var err := CATCH( { var col_upd :=
collection_name.mirror().[lng]().[str]().[+]("_map_pid").[bat]().[int]().[ttype]().[=](oid).tmark([EMAIL
PROTECTED]).[str]();
+ doc_nme :=
mirror(doc_name.[startsWith]("::").uselect(false));
doc_url := doc_nme.leftjoin(doc_location).tmark([EMAIL
PROTECTED]);
doc_col :=
doc_nme.leftjoin(doc_collection).tmark([EMAIL PROTECTED]);
- doc_upd :=
doc_col.[lng]().[str]().[+]("_map_pid").[bat]().[int]().[ttype]().[=](oid).tmark([EMAIL
PROTECTED]).[str]();
+ doc_upd := doc_col.leftjoin(col_upd).tmark([EMAIL
PROTECTED]);
doc_nme := doc_nme.leftjoin(doc_name).tmark([EMAIL
PROTECTED]);
doc_col :=
doc_col.leftjoin(collection_name).tmark([EMAIL PROTECTED]); });
lock_unset(pf_short);
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins