aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-03-31 16:58:51 +0200
committerThomas White <taw@physics.org>2021-03-31 16:58:51 +0200
commit504f6465c3b872792fa17aa6c01ce6045fb06922 (patch)
tree180b99cdb0ccda33bad678d4d955e5c03f21368c
parent5e17c1718234b2e7aea37cdb59081ed1d79e8914 (diff)
indexamajig: Handle spaces in filename when retrieving ID from queue
-rw-r--r--src/im-sandbox.c49
1 files changed, 41 insertions, 8 deletions
diff --git a/src/im-sandbox.c b/src/im-sandbox.c
index 955e21e2..6615c418 100644
--- a/src/im-sandbox.c
+++ b/src/im-sandbox.c
@@ -343,13 +343,17 @@ static int run_work(const struct index_args *iargs, Stream *st,
while ( !allDone ) {
struct pattern_args pargs;
- char filename[MAX_EV_LEN];
- char event_str[MAX_EV_LEN];
int ser;
- int r;
if ( !sb->zmq ) {
+ char *line;
+ size_t len;
+ int i;
+ char *event_str = NULL;
+ char *ser_str = NULL;
+ int ok = 1;
+
/* Wait until an event is ready */
time_accounts_set(taccs, TACC_EVENTWAIT);
set_last_task(sb->shared->last_task[cookie], "wait_event");
@@ -378,22 +382,51 @@ static int run_work(const struct index_args *iargs, Stream *st,
allDone = 1;
continue;
}
- r = sscanf(sb->shared->queue[0], "%s %s %i",
- filename, event_str, &ser);
- if ( r != 3 ) {
+
+ line = strdup(sb->shared->queue[0]);
+
+ len = strlen(line);
+ assert(len > 1);
+ for ( i=len-1; i>0; i-- ) {
+ if ( line[i] == ' ' ) {
+ line[i] = '\0';
+ ser_str = &line[i+1];
+ break;
+ }
+ }
+ len = strlen(line);
+ assert(len > 1);
+ for ( i=len-1; i>0; i-- ) {
+ if ( line[i] == ' ' ) {
+ line[i] = '\0';
+ event_str = &line[i+1];
+ break;
+ }
+ }
+ if ( (ser_str != NULL) && (event_str != NULL) ) {
+ if ( sscanf(ser_str, "%i", &ser) != 1 ) {
+ STATUS("Invalid serial number '%s'\n",
+ ser_str);
+ ok = 0;
+ }
+ }
+ if ( !ok ) {
STATUS("Invalid event string '%s'\n",
sb->shared->queue[0]);
+ ok = 0;
}
memcpy(sb->shared->last_ev[cookie], sb->shared->queue[0],
MAX_EV_LEN);
shuffle_events(sb->shared);
pthread_mutex_unlock(&sb->shared->queue_lock);
- if ( r != 3 ) continue;
+ if ( !ok ) continue;
- pargs.filename = strdup(filename);
+ pargs.filename = strdup(line);
pargs.event = strdup(event_str);
+ free(line);
+
pargs.msgpack_obj = NULL;
} else {