Merge branch '46-just-use-clang-format-to-reformat-sources' into 'master'
Reformat source code with clang-format Closes #46 See merge request isc-projects/bind9!2156 (cherry picked from commit7099e79a9b)4c3b063eImport Linux kernel .clang-format with small modificationsf50b1e06Use clang-format to reformat the source files11341c76Update the definition files for Windowsdf6c1f76Remove tkey_test (which is no-op anyway)
This commit is contained in:
@@ -12,65 +12,66 @@
|
||||
#include <isc/app.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/print.h>
|
||||
#include <isc/ratelimiter.h>
|
||||
#include <isc/task.h>
|
||||
#include <isc/time.h>
|
||||
#include <isc/timer.h>
|
||||
#include <isc/ratelimiter.h>
|
||||
#include <isc/util.h>
|
||||
|
||||
isc_ratelimiter_t *rlim = NULL;
|
||||
isc_taskmgr_t *taskmgr = NULL;
|
||||
isc_timermgr_t *timermgr = NULL;
|
||||
isc_task_t *g_task = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_taskmgr_t * taskmgr = NULL;
|
||||
isc_timermgr_t * timermgr = NULL;
|
||||
isc_task_t * g_task = NULL;
|
||||
isc_mem_t * mctx = NULL;
|
||||
|
||||
static void utick(isc_task_t *task, isc_event_t *event);
|
||||
static void shutdown_rl(isc_task_t *task, isc_event_t *event);
|
||||
static void shutdown_all(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
utick(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
shutdown_rl(isc_task_t *task, isc_event_t *event);
|
||||
static void
|
||||
shutdown_all(isc_task_t *task, isc_event_t *event);
|
||||
|
||||
typedef struct {
|
||||
int milliseconds;
|
||||
void (*fun)(isc_task_t *, isc_event_t *);
|
||||
} schedule_t;
|
||||
|
||||
schedule_t schedule[] = {
|
||||
{ 100, utick },
|
||||
{ 200, utick },
|
||||
{ 300, utick },
|
||||
{ 3000, utick },
|
||||
{ 3100, utick },
|
||||
{ 3200, utick },
|
||||
{ 3300, shutdown_rl },
|
||||
{ 5000, utick },
|
||||
{ 6000, shutdown_all }
|
||||
};
|
||||
schedule_t schedule[] = { { 100, utick }, { 200, utick },
|
||||
{ 300, utick }, { 3000, utick },
|
||||
{ 3100, utick }, { 3200, utick },
|
||||
{ 3300, shutdown_rl }, { 5000, utick },
|
||||
{ 6000, shutdown_all } };
|
||||
|
||||
#define NEVENTS (int)(sizeof(schedule)/sizeof(schedule[0]))
|
||||
#define NEVENTS (int)(sizeof(schedule) / sizeof(schedule[0]))
|
||||
|
||||
isc_timer_t *timers[NEVENTS];
|
||||
|
||||
static void
|
||||
ltick(isc_task_t *task, isc_event_t *event) {
|
||||
ltick(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
UNUSED(task);
|
||||
printf("** ltick%s **\n",
|
||||
(event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0 ?
|
||||
" (canceled)" : "");
|
||||
(event->ev_attributes & ISC_EVENTATTR_CANCELED) != 0 ? " ("
|
||||
"canceled"
|
||||
")"
|
||||
: "");
|
||||
isc_event_free(&event);
|
||||
}
|
||||
|
||||
static void
|
||||
utick(isc_task_t *task, isc_event_t *event) {
|
||||
utick(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
isc_result_t result;
|
||||
UNUSED(task);
|
||||
event->ev_action = ltick;
|
||||
event->ev_sender = NULL;
|
||||
result = isc_ratelimiter_enqueue(rlim, g_task, &event);
|
||||
printf("enqueue: %s\n",
|
||||
result == ISC_R_SUCCESS ? "ok" : "failed");
|
||||
printf("enqueue: %s\n", result == ISC_R_SUCCESS ? "ok" : "failed");
|
||||
}
|
||||
|
||||
static void
|
||||
shutdown_rl(isc_task_t *task, isc_event_t *event) {
|
||||
shutdown_rl(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
UNUSED(task);
|
||||
UNUSED(event);
|
||||
printf("shutdown ratelimiter\n");
|
||||
@@ -78,7 +79,8 @@ shutdown_rl(isc_task_t *task, isc_event_t *event) {
|
||||
}
|
||||
|
||||
static void
|
||||
shutdown_all(isc_task_t *task, isc_event_t *event) {
|
||||
shutdown_all(isc_task_t *task, isc_event_t *event)
|
||||
{
|
||||
int i;
|
||||
UNUSED(task);
|
||||
UNUSED(event);
|
||||
@@ -91,9 +93,10 @@ shutdown_all(isc_task_t *task, isc_event_t *event) {
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[]) {
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
isc_interval_t linterval;
|
||||
int i;
|
||||
int i;
|
||||
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
@@ -104,27 +107,23 @@ main(int argc, char *argv[]) {
|
||||
isc_mem_create(&mctx);
|
||||
RUNTIME_CHECK(isc_taskmgr_create(mctx, 3, 0, NULL, &taskmgr) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &g_task) ==
|
||||
ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_timermgr_create(mctx, &timermgr) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_task_create(taskmgr, 0, &g_task) == ISC_R_SUCCESS);
|
||||
|
||||
RUNTIME_CHECK(isc_ratelimiter_create(mctx, timermgr, g_task,
|
||||
&rlim) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(isc_ratelimiter_create(mctx, timermgr, g_task, &rlim) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
RUNTIME_CHECK(isc_ratelimiter_setinterval(rlim, &linterval) ==
|
||||
ISC_R_SUCCESS);
|
||||
|
||||
for (i = 0; i < NEVENTS; i++) {
|
||||
isc_interval_t uinterval;
|
||||
int ms = schedule[i].milliseconds;
|
||||
isc_interval_set(&uinterval, ms / 1000,
|
||||
(ms % 1000) * 1000000);
|
||||
int ms = schedule[i].milliseconds;
|
||||
isc_interval_set(&uinterval, ms / 1000, (ms % 1000) * 1000000);
|
||||
timers[i] = NULL;
|
||||
RUNTIME_CHECK(isc_timer_create(timermgr,
|
||||
isc_timertype_once, NULL,
|
||||
&uinterval,
|
||||
g_task, schedule[i].fun, NULL,
|
||||
RUNTIME_CHECK(isc_timer_create(timermgr, isc_timertype_once,
|
||||
NULL, &uinterval, g_task,
|
||||
schedule[i].fun, NULL,
|
||||
&timers[i]) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user