Skip to content

Commit

Permalink
Merge pull request #262 from haiwen/add-ctime
Browse files Browse the repository at this point in the history
add ctime
  • Loading branch information
killing authored Sep 9, 2019
2 parents 9a1b17f + f01753c commit d4d026d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 8 deletions.
9 changes: 6 additions & 3 deletions common/mq-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static GAsyncQueue *
seaf_mq_manager_channel_new (SeafMqManager *mgr, const char *channel)
{
GAsyncQueue *async_queue = NULL;
async_queue = g_async_queue_new_full ((GDestroyNotify)g_free);
async_queue = g_async_queue_new_full ((GDestroyNotify)json_decref);

g_hash_table_replace (mgr->priv->chans, g_strdup (channel), async_queue);

Expand All @@ -51,12 +51,15 @@ seaf_mq_manager_publish_event (SeafMqManager *mgr, const char *channel, const ch
return -1;
}

g_async_queue_push (async_queue, g_strdup (content));
json_t *msg = json_object();
json_object_set_new (msg, "content", json_string(content));
json_object_set_new (msg, "ctime", json_integer(time(NULL)));
g_async_queue_push (async_queue, msg);

return ret;
}

char *
json_t *
seaf_mq_manager_pop_event (SeafMqManager *mgr, const char *channel)
{
GAsyncQueue *async_queue = g_hash_table_lookup (mgr->priv->chans, channel);
Expand Down
2 changes: 1 addition & 1 deletion common/mq-mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ seaf_mq_manager_new ();
int
seaf_mq_manager_publish_event (SeafMqManager *mgr, const char *channel, const char *content);

char *
json_t *
seaf_mq_manager_pop_event (SeafMqManager *mgr, const char *channel);

#endif
2 changes: 1 addition & 1 deletion common/rpc-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ seafile_publish_event(const char *channel, const char *content, GError **error)
return ret;
}

char*
json_t *
seafile_pop_event(const char *channel, GError **error)
{
if (!channel) {
Expand Down
2 changes: 1 addition & 1 deletion include/seafile-rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,6 @@ seafile_get_repo_status(const char *repo_id, GError **error);
int
seafile_publish_event(const char *channel, const char *content, GError **error);

char*
json_t *
seafile_pop_event(const char *channel, GError **error);
#endif
1 change: 1 addition & 0 deletions lib/rpc_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@
[ "object", ["string", "string", "string", "int"] ],
[ "object", ["string", "string", "string", "string", "string", "string", "string", "int", "int"] ],
[ "object", ["string", "string", "string", "string", "string", "string", "int", "string", "int", "int"] ],
["json", ["string"]],
]
2 changes: 1 addition & 1 deletion python/seafile/rpcclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ def cancel_copy_task(task_id):
def publish_event(channel, content):
pass

@searpc_func("string", ["string"])
@searpc_func("json", ["string"])
def pop_event(channel):
pass

2 changes: 1 addition & 1 deletion server/seaf-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ static void start_rpc_service (const char *seafile_dir)
searpc_server_register_function ("seafserv-threaded-rpcserver",
seafile_pop_event,
"pop_event",
searpc_signature_string__string());
searpc_signature_json__string());


searpc_server_register_function ("seafserv-threaded-rpcserver",
Expand Down

0 comments on commit d4d026d

Please sign in to comment.