diff options
author | Thomas White <taw@physics.org> | 2019-03-08 19:44:06 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-03-14 11:36:57 +0100 |
commit | 994c14337ecf9a754ebd40ca78fc384a527cd353 (patch) | |
tree | 38f9bc3bd0b2f7bb34de4dd6c54c41186e4eb52b /src | |
parent | de09b82310f7b464e4095d1b750d9b968c84b6ed (diff) |
More ZMQ/MsgPack logic fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/im-sandbox.c | 5 | ||||
-rw-r--r-- | src/im-zmq.c | 8 | ||||
-rw-r--r-- | src/process_image.c | 8 |
3 files changed, 13 insertions, 8 deletions
diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 20bd6c94..3567a722 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -453,7 +453,10 @@ static int run_work(const struct index_args *iargs, Stream *st, } else { pargs.msgpack_obj = im_zmq_fetch(zmqstuff); - pargs.filename_p_e = NULL; + pargs.filename_p_e = initialize_filename_plus_event(); + pargs.filename_p_e->filename = strdup("(from ZMQ)"); + pargs.filename_p_e->ev = NULL; + ser = 0; /* FIXME */ } diff --git a/src/im-zmq.c b/src/im-zmq.c index 4503acff..3efb6607 100644 --- a/src/im-zmq.c +++ b/src/im-zmq.c @@ -145,9 +145,11 @@ static msgpack_object *find_msgpack_kv(msgpack_object *obj, const char *key) for ( i=0; i<obj->via.map.size; i++ ) { const char *kstr; + size_t klen; assert(obj->via.map.ptr[i].key.type == MSGPACK_OBJECT_STR); kstr = obj->via.map.ptr[i].key.via.str.ptr; - if ( strcmp(kstr, key) == 0 ) { + klen = obj->via.map.ptr[i].key.via.str.size; + if ( strncmp(kstr, key, klen) == 0 ) { return &obj->via.map.ptr[i].val; } } @@ -318,11 +320,11 @@ int unpack_msgpack_data(msgpack_object *obj, struct image *image) ERROR("No data MessagePack object found inside corr_data.\n"); return 1; } - if ( data_obj->type != MSGPACK_OBJECT_BIN ) { + if ( data_obj->type != MSGPACK_OBJECT_STR ) { ERROR("corr_data.data isn't a binary object.\n"); return 1; } - data = (double *)data_obj->via.bin.ptr; + data = (double *)data_obj->via.str.ptr; shape_obj = find_msgpack_kv(corr_data_obj, "shape"); if ( shape_obj == NULL ) { diff --git a/src/process_image.c b/src/process_image.c index 3dd02aaa..acd85bcb 100644 --- a/src/process_image.c +++ b/src/process_image.c @@ -214,12 +214,12 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs, image.serial = serial; image.indexed_by = INDEXING_NONE; + image.filename = pargs->filename_p_e->filename; + image.event = pargs->filename_p_e->ev; if ( pargs->msgpack_obj != NULL ) { STATUS("Msgpack!\n"); if ( unpack_msgpack_data(pargs->msgpack_obj, &image) ) return; - } else if ( pargs->filename_p_e != NULL ) { - image.filename = pargs->filename_p_e->filename; - image.event = pargs->filename_p_e->ev; + } else { if ( file_wait_open_read(sb_shared, &image, taccs, last_task, iargs->wait_for_file, cookie, &imfile) ) return; @@ -500,5 +500,5 @@ out: image_feature_list_free(image.features); free_detector_geometry(image.det); - imagefile_close(imfile); + if ( imfile != NULL ) imagefile_close(imfile); } |