mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-24 07:16:43 +00:00
45442d3eb4
Replaced 'int has_author' manifest element with new 'enum authorship' element to record the result of author authentication, to avoid repeating expensive crypto operations. Separated the handling of bundle secret arguments from author lookup and authentication. The new rhizome_apply_bundle_secret(m,bsk) is now called at the top level to set the manifest secret key (if it validates), and thereafter there is no need to pass the 'bsk' argument to any other functions, as they can simply check the 'haveSecret' field of the manifest. Removed rhizome_extract_privatekey() which combined author lookup and bundle secret validation, and replaced it with functions that only deal with the author: rhizome_lookup_author() and rhizome_authenticate_author(). Renamed other functions to make their purpose and effect clearer. Formalised the semantics of only storing AUTHENTICATED author SIDs in the 'author' column of the MANIFESTS table, which necessitated a change to a 'rhizomeops' test case: when adding a file using a BK-less manifest, the author column is set to null, so the Rhizome list output does not show the bundle as ".fromhere" and does not give an author for that bundle.
94 lines
2.8 KiB
C
94 lines
2.8 KiB
C
/*
|
|
Serval DNA file descriptor queue
|
|
Copyright (C) 2012-2013 Serval Project, Inc.
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License
|
|
as published by the Free Software Foundation; either version 2
|
|
of the License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef __SERVALDNA__FDQUEUE_H
|
|
#define __SERVALDNA__FDQUEUE_H
|
|
|
|
#ifdef HAVE_POLL_H
|
|
#include <poll.h>
|
|
#endif
|
|
#include "os.h"
|
|
#include "log.h"
|
|
|
|
struct profile_total {
|
|
struct profile_total *_next;
|
|
int _initialised;
|
|
const char *name;
|
|
time_ms_t max_time;
|
|
time_ms_t total_time;
|
|
time_ms_t child_time;
|
|
int calls;
|
|
};
|
|
|
|
struct call_stats{
|
|
time_ms_t enter_time;
|
|
time_ms_t child_time;
|
|
struct profile_total *totals;
|
|
struct call_stats *prev;
|
|
};
|
|
|
|
struct sched_ent;
|
|
|
|
typedef void (*ALARM_FUNCP) (struct sched_ent *alarm);
|
|
|
|
struct sched_ent{
|
|
struct sched_ent *_next;
|
|
struct sched_ent *_prev;
|
|
|
|
ALARM_FUNCP function;
|
|
void *context;
|
|
struct pollfd poll;
|
|
// when we should first consider the alarm
|
|
time_ms_t alarm;
|
|
// the order we will prioritise the alarm
|
|
time_ms_t deadline;
|
|
struct profile_total *stats;
|
|
int _poll_index;
|
|
};
|
|
|
|
int is_scheduled(const struct sched_ent *alarm);
|
|
int _schedule(struct __sourceloc, struct sched_ent *alarm);
|
|
int _unschedule(struct __sourceloc, struct sched_ent *alarm);
|
|
int _watch(struct __sourceloc, struct sched_ent *alarm);
|
|
int _unwatch(struct __sourceloc, struct sched_ent *alarm);
|
|
#define schedule(alarm) _schedule(__WHENCE__, alarm)
|
|
#define unschedule(alarm) _unschedule(__WHENCE__, alarm)
|
|
#define watch(alarm) _watch(__WHENCE__, alarm)
|
|
#define unwatch(alarm) _unwatch(__WHENCE__, alarm)
|
|
int fd_poll();
|
|
|
|
/* function timing routines */
|
|
int fd_clearstats();
|
|
int fd_showstats();
|
|
int fd_checkalarms();
|
|
int fd_func_enter(struct __sourceloc, struct call_stats *this_call);
|
|
int fd_func_exit(struct __sourceloc, struct call_stats *this_call);
|
|
void dump_stack(int log_level);
|
|
|
|
#define IN() static struct profile_total _aggregate_stats={NULL,0,__FUNCTION__,0,0,0}; \
|
|
struct call_stats _this_call={.totals=&_aggregate_stats}; \
|
|
fd_func_enter(__HERE__, &_this_call);
|
|
|
|
#define OUT() fd_func_exit(__HERE__, &_this_call)
|
|
#define RETURN(X) do { OUT(); return (X); } while (0);
|
|
#define RETURNNULL do { OUT(); return (NULL); } while (0);
|
|
#define RETURNVOID do { OUT(); return; } while (0);
|
|
|
|
#endif // __SERVALDNA__FDQUEUE_H
|