Vague attempt at some more cleanup, and stick pthread_self() in the traces.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4176 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
parent
1f77df7a90
commit
6b5d73ed5c
16
src/ssb.c
16
src/ssb.c
@ -685,12 +685,12 @@ void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags,
|
||||
{
|
||||
if (!connection)
|
||||
{
|
||||
if (cleanup)
|
||||
{
|
||||
cleanup(NULL, user_data);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (request_number > 0 && callback)
|
||||
{
|
||||
tf_ssb_connection_add_request(connection, request_number, callback, cleanup, user_data, NULL);
|
||||
}
|
||||
uint8_t* combined = tf_malloc(9 + size);
|
||||
*combined = flags;
|
||||
uint32_t u32size = htonl((uint32_t)size);
|
||||
@ -706,6 +706,14 @@ void tf_ssb_connection_rpc_send(tf_ssb_connection_t* connection, uint8_t flags,
|
||||
_tf_ssb_connection_box_stream_send(connection, combined, 1 + 2 * sizeof(uint32_t) + size);
|
||||
tf_free(combined);
|
||||
connection->ssb->rpc_out++;
|
||||
if (request_number > 0 && callback)
|
||||
{
|
||||
tf_ssb_connection_add_request(connection, request_number, callback, cleanup, user_data, NULL);
|
||||
}
|
||||
else if (cleanup)
|
||||
{
|
||||
cleanup(connection->ssb, user_data);
|
||||
}
|
||||
}
|
||||
|
||||
void tf_ssb_connection_rpc_send_json(tf_ssb_connection_t* connection, uint8_t flags, int32_t request_number, JSValue message, tf_ssb_rpc_callback_t* callback, tf_ssb_callback_cleanup_t* cleanup, void* user_data)
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "mem.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
@ -173,7 +174,7 @@ void tf_trace_begin(tf_trace_t* trace, const char* name)
|
||||
stack->names[stack->count++] = name;
|
||||
|
||||
char line[1024];
|
||||
int p = snprintf(line, sizeof(line), "{\"ph\": \"B\", \"pid\": %d, \"tid\": 0, \"ts\": %" PRId64 ", \"name\": \"", getpid(), _trace_ts());
|
||||
int p = snprintf(line, sizeof(line), "{\"ph\": \"B\", \"pid\": %d, \"tid\": %" PRId64 ", \"ts\": %" PRId64 ", \"name\": \"", getpid(), (int64_t)pthread_self(), _trace_ts());
|
||||
p += _tf_trace_escape_name(line + p, sizeof(line) - p, name);
|
||||
p += snprintf(line + p, sizeof(line) - p, "\"},");
|
||||
trace->callback(trace, line, p, trace->user_data);
|
||||
@ -203,7 +204,7 @@ void tf_trace_end(tf_trace_t* trace)
|
||||
}
|
||||
|
||||
char line[1024];
|
||||
int p = snprintf(line, sizeof(line), "{\"ph\": \"E\", \"pid\": %d, \"tid\": 0, \"ts\": %" PRId64 ", \"name\": \"", getpid(), _trace_ts());
|
||||
int p = snprintf(line, sizeof(line), "{\"ph\": \"E\", \"pid\": %d, \"tid\": %" PRId64 ", \"ts\": %" PRId64 ", \"name\": \"", getpid(), (int64_t)pthread_self(), _trace_ts());
|
||||
p += _tf_trace_escape_name(line + p, sizeof(line) - p, name);
|
||||
p += snprintf(line + p, sizeof(line) - p, "\"},");
|
||||
trace->callback(trace, line, p, trace->user_data);
|
||||
|
Loading…
Reference in New Issue
Block a user