aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_common.h
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-05-10 20:08:01 +0200
committerFlorian Dold <florian.dold@gmail.com>2019-05-10 20:10:02 +0200
commitc1f06ac28fef5498952994e0399312b1fc567f22 (patch)
treead71f80bb08bfe20ff33880509263d78f334409b /src/include/gnunet_common.h
parentd1d18e6492708a0ce758ddd8c509f21b0ecbf6a0 (diff)
downloadgnunet-c1f06ac28fef5498952994e0399312b1fc567f22.tar.gz
gnunet-c1f06ac28fef5498952994e0399312b1fc567f22.zip
Implement asynchronous scope identifiers.
Without entering an asynchronous scope, logs are the same before. When entering an asynchronous scope (either thread-based of scheduler/task-based), all log lines within an asynchronous scope contain its ID. Currently this is only used in GNU Taler, for debugging requests across multiple services. This allows us to get all log lines pertaining to a particular request for a user or another service.
Diffstat (limited to 'src/include/gnunet_common.h')
-rw-r--r--src/include/gnunet_common.h64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 2c40aef79..1f5600381 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -319,8 +319,34 @@ struct GNUNET_OperationResultMessage
319 /* Followed by data. */ 319 /* Followed by data. */
320}; 320};
321 321
322
323/**
324 * Identifier for an asynchronous execution context.
325 */
326struct GNUNET_AsyncScopeId
327{
328 uint32_t bits[16 / sizeof (uint32_t)]; /* = 16 bytes */
329};
330
322GNUNET_NETWORK_STRUCT_END 331GNUNET_NETWORK_STRUCT_END
323 332
333
334/**
335 * Saved async scope identifier or root scope.
336 */
337struct GNUNET_AsyncScopeSave {
338 /**
339 * Saved scope. Unused if 'have_scope==GNUNET_NO'.
340 */
341 struct GNUNET_AsyncScopeId scope_id;
342
343 /**
344 * GNUNET_YES unless this saved scope is the unnamed root scope.
345 */
346 int have_scope;
347};
348
349
324/** 350/**
325 * Function called with a filename. 351 * Function called with a filename.
326 * 352 *
@@ -1331,6 +1357,44 @@ struct GNUNET_MessageHeader *
1331GNUNET_copy_message (const struct GNUNET_MessageHeader *msg); 1357GNUNET_copy_message (const struct GNUNET_MessageHeader *msg);
1332 1358
1333 1359
1360/**
1361 * Set the async scope for the current thread.
1362 *
1363 * @param aid the async scope identifier
1364 * @param old_scope[out] location to save the old scope
1365 */
1366void
1367GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid,
1368 struct GNUNET_AsyncScopeSave *old_scope);
1369
1370
1371/**
1372 * Clear the current thread's async scope.
1373 *
1374 * @param old_scope scope to restore
1375 */
1376void
1377GNUNET_async_scope_restore (struct GNUNET_AsyncScopeSave *old_scope);
1378
1379
1380/**
1381 * Get the current async scope.
1382 *
1383 * @param[out] scope_ret pointer to where the result is stored
1384 */
1385void
1386GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret);
1387
1388
1389/**
1390 * Generate a fresh async scope identifier.
1391 *
1392 * @param[out] aid_ret pointer to where the result is stored
1393 */
1394void
1395GNUNET_async_scope_fresh (struct GNUNET_AsyncScopeId *aid_ret);
1396
1397
1334#if __STDC_VERSION__ < 199901L 1398#if __STDC_VERSION__ < 199901L
1335#if __GNUC__ >= 2 1399#if __GNUC__ >= 2
1336#define __func__ __FUNCTION__ 1400#define __func__ __FUNCTION__