aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlurchi <lurchi@strangeplace.net>2017-08-05 13:35:10 +0200
committerlurchi <lurchi@strangeplace.net>2017-08-05 13:35:10 +0200
commitdf4dae1db83ca19b0ba0ddef64699b89558675ed (patch)
treed8300e68c64d784ad014799556d9365d8100a1c6 /src
parente8e8d889a4c92a36ec1491f8b255457cd42922d3 (diff)
downloadgnunet-df4dae1db83ca19b0ba0ddef64699b89558675ed.tar.gz
gnunet-df4dae1db83ca19b0ba0ddef64699b89558675ed.zip
fix warnings
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_scheduler_lib.h4
-rw-r--r--src/util/scheduler.c100
2 files changed, 49 insertions, 55 deletions
diff --git a/src/include/gnunet_scheduler_lib.h b/src/include/gnunet_scheduler_lib.h
index 5baf4806d..837a23ba5 100644
--- a/src/include/gnunet_scheduler_lib.h
+++ b/src/include/gnunet_scheduler_lib.h
@@ -280,7 +280,7 @@ struct GNUNET_SCHEDULER_Driver
280 int 280 int
281 (*add)(void *cls, 281 (*add)(void *cls,
282 struct GNUNET_SCHEDULER_Task *task, 282 struct GNUNET_SCHEDULER_Task *task,
283 const struct GNUNET_SCHEDULER_FdInfo *fdi); 283 struct GNUNET_SCHEDULER_FdInfo *fdi);
284 284
285 /** 285 /**
286 * Delete a @a task from the set of tasks to be run. 286 * Delete a @a task from the set of tasks to be run.
@@ -294,7 +294,7 @@ struct GNUNET_SCHEDULER_Driver
294 int 294 int
295 (*del)(void *cls, 295 (*del)(void *cls,
296 struct GNUNET_SCHEDULER_Task *task, 296 struct GNUNET_SCHEDULER_Task *task,
297 const struct GNUNET_SCHEDULER_FdInfo *fdi); 297 struct GNUNET_SCHEDULER_FdInfo *fdi);
298 298
299 /** 299 /**
300 * Set time at which we definitively want to get a wakeup call. 300 * Set time at which we definitively want to get a wakeup call.
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index e442989d0..7a65069a2 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -791,7 +791,7 @@ check_lifeness ()
791 791
792 792
793 793
794void while_live(struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws) 794int while_live(struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws)
795{ 795{
796 int ret; 796 int ret;
797 unsigned int busy_wait_warning; 797 unsigned int busy_wait_warning;
@@ -908,6 +908,7 @@ void while_live(struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws
908 busy_wait_warning = 0; 908 busy_wait_warning = 0;
909 } 909 }
910 } 910 }
911 return ret;
911} 912}
912 913
913/** 914/**
@@ -929,7 +930,7 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_TaskCallback task,
929 void *task_cls) 930 void *task_cls)
930{ 931{
931 932
932 GNUNET_SCHEDULER_run_with_driver(GNUNET_SCHEDULER_driver_select, task, task_cls); 933 GNUNET_SCHEDULER_run_with_driver(GNUNET_SCHEDULER_driver_select (), task, task_cls);
933 934
934} 935}
935 936
@@ -974,18 +975,14 @@ GNUNET_SCHEDULER_get_load (enum GNUNET_SCHEDULER_Priority p)
974 return ret; 975 return ret;
975} 976}
976 977
977static struct GNUNET_SCHEDULER_Task* 978
978initFdInfo(const struct GNUNET_NETWORK_Handle *read_nh, 979void
980initFdInfo(struct GNUNET_SCHEDULER_Task *t,
981 const struct GNUNET_NETWORK_Handle *read_nh,
979 const struct GNUNET_NETWORK_Handle *write_nh, 982 const struct GNUNET_NETWORK_Handle *write_nh,
980 const struct GNUNET_DISK_FileHandle *read_fh, 983 const struct GNUNET_DISK_FileHandle *read_fh,
981 const struct GNUNET_DISK_FileHandle *write_fh) 984 const struct GNUNET_DISK_FileHandle *write_fh)
982{ 985{
983
984
985 struct GNUNET_SCHEDULER_Task *t;
986
987 t = GNUNET_new (struct GNUNET_SCHEDULER_Task);
988
989 // either only network handles or only file handles are allowed 986 // either only network handles or only file handles are allowed
990 GNUNET_assert (!((NULL != read_nh || NULL != write_nh) && (NULL != read_fh || NULL != write_fh))); 987 GNUNET_assert (!((NULL != read_nh || NULL != write_nh) && (NULL != read_fh || NULL != write_fh)));
991 988
@@ -1020,16 +1017,31 @@ initFdInfo(const struct GNUNET_NETWORK_Handle *read_nh,
1020 } 1017 }
1021 else if (NULL != read_fh) 1018 else if (NULL != read_fh)
1022 { 1019 {
1023 struct GNUNET_SCHEDULER_FdInfo read_fdi = { .fh = read_fh, .et = GNUNET_SCHEDULER_ET_IN}; 1020 struct GNUNET_SCHEDULER_FdInfo read_fdi = { .fh = read_fh, .et = GNUNET_SCHEDULER_ET_IN, .sock = read_fh->fd};
1024 t->fdx = read_fdi; 1021 t->fdx = read_fdi;
1025 } 1022 }
1026 else if (NULL != write_fh) 1023 else if (NULL != write_fh)
1027 { 1024 {
1028 struct GNUNET_SCHEDULER_FdInfo write_fdi = { .fh = write_fh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = GNUNET_NETWORK_get_fd (write_nh)}; 1025 struct GNUNET_SCHEDULER_FdInfo write_fdi = { .fh = write_fh, .et = GNUNET_SCHEDULER_ET_OUT, .sock = write_fh->fd};
1029 t->fdx = write_fdi; 1026 t->fdx = write_fdi;
1030 } 1027 }
1031} 1028}
1032 1029
1030
1031int scheduler_multi_function_call(struct GNUNET_SCHEDULER_Task *t, int (*driver_func)())
1032{
1033 if (t->fds_len > 1){
1034 int success = GNUNET_YES;
1035 for (int i = 0; i < t->fds_len;i++){
1036 success = driver_func(scheduler_driver->cls, t , t->fds+i) && success;
1037 }
1038 return success;
1039 }else{
1040 return driver_func(scheduler_driver->cls, t , t->fds);
1041 }
1042}
1043
1044
1033/** 1045/**
1034 * Cancel the task with the specified identifier. 1046 * Cancel the task with the specified identifier.
1035 * The task must not yet have run. 1047 * The task must not yet have run.
@@ -1066,6 +1078,9 @@ GNUNET_SCHEDULER_cancel (struct GNUNET_SCHEDULER_Task *task)
1066 } 1078 }
1067 else 1079 else
1068 { 1080 {
1081 GNUNET_CONTAINER_DLL_remove (pending_head,
1082 pending_tail,
1083 task);
1069 scheduler_multi_function_call(task, scheduler_driver->del); 1084 scheduler_multi_function_call(task, scheduler_driver->del);
1070 } 1085 }
1071 } 1086 }
@@ -1410,20 +1425,6 @@ GNUNET_SCHEDULER_add_now_with_lifeness (int lifeness,
1410} 1425}
1411 1426
1412 1427
1413
1414int scheduler_multi_function_call(struct GNUNET_SCHEDULER_Task *t, int (*driver_func)())
1415{
1416 if (t->fds_len > 1){
1417 int success = GNUNET_YES;
1418 for (int i = 0; i < t->fds_len;i++){
1419 success = driver_func(scheduler_driver->cls, t , t->fds+i) && success;
1420 }
1421 return success;
1422 }else{
1423 return driver_func(scheduler_driver->cls, t , t->fds);
1424 }
1425}
1426
1427/** 1428/**
1428 * Schedule a new task to be run with a specified delay or when any of 1429 * Schedule a new task to be run with a specified delay or when any of
1429 * the specified file descriptor sets is ready. The delay can be used 1430 * the specified file descriptor sets is ready. The delay can be used
@@ -1466,8 +1467,8 @@ add_without_sets (struct GNUNET_TIME_Relative delay,
1466 1467
1467 GNUNET_assert (NULL != active_task); 1468 GNUNET_assert (NULL != active_task);
1468 GNUNET_assert (NULL != task); 1469 GNUNET_assert (NULL != task);
1469 t= initFdInfo (read_nh, write_nh, read_fh, write_fh); 1470 t = GNUNET_new (struct GNUNET_SCHEDULER_Task);
1470 1471 initFdInfo (t, read_nh, write_nh, read_fh, write_fh);
1471 t->callback = task; 1472 t->callback = task;
1472 t->callback_cls = task_cls; 1473 t->callback_cls = task_cls;
1473#if DEBUG_FDS 1474#if DEBUG_FDS
@@ -1505,11 +1506,10 @@ add_without_sets (struct GNUNET_TIME_Relative delay,
1505 t->timeout = GNUNET_TIME_relative_to_absolute (delay); 1506 t->timeout = GNUNET_TIME_relative_to_absolute (delay);
1506 t->priority = check_priority ((priority == GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority : priority); 1507 t->priority = check_priority ((priority == GNUNET_SCHEDULER_PRIORITY_KEEP) ? current_priority : priority);
1507 t->lifeness = current_lifeness; 1508 t->lifeness = current_lifeness;
1508 1509 GNUNET_CONTAINER_DLL_insert (pending_head,
1509 1510 pending_tail,
1510 1511 t);
1511 scheduler_multi_function_call(t, scheduler_driver->add); 1512 scheduler_multi_function_call(t, scheduler_driver->add);
1512
1513 max_priority_added = GNUNET_MAX (max_priority_added, 1513 max_priority_added = GNUNET_MAX (max_priority_added,
1514 t->priority); 1514 t->priority);
1515 LOG (GNUNET_ERROR_TYPE_DEBUG, 1515 LOG (GNUNET_ERROR_TYPE_DEBUG,
@@ -2103,40 +2103,34 @@ GNUNET_SCHEDULER_run_with_driver (const struct GNUNET_SCHEDULER_Driver *driver,
2103 2103
2104int 2104int
2105select_add(void *cls, 2105select_add(void *cls,
2106 struct GNUNET_SCHEDULER_Task *task, 2106 struct GNUNET_SCHEDULER_Task *task,
2107 struct GNUNET_SCHEDULER_FdInfo *fdi){ 2107 struct GNUNET_SCHEDULER_FdInfo *fdi)
2108 2108{
2109 GNUNET_CONTAINER_DLL_insert (pending_head, 2109 return GNUNET_OK;
2110 pending_tail,
2111 task);
2112
2113} 2110}
2114 2111
2112
2115int 2113int
2116select_del(void *cls, 2114select_del(void *cls,
2117 struct GNUNET_SCHEDULER_Task *task, 2115 struct GNUNET_SCHEDULER_Task *task,
2118 struct GNUNET_SCHEDULER_FdInfo *fdi){ 2116 struct GNUNET_SCHEDULER_FdInfo *fdi)
2119 2117{
2120 GNUNET_CONTAINER_DLL_remove (pending_head, 2118 return GNUNET_OK;
2121 pending_tail,
2122 task);
2123
2124} 2119}
2125 2120
2126 2121
2127int 2122int
2128select_loop(void *cls, 2123select_loop(void *cls,
2129 struct GNUNET_SCHEDULER_Handle *sh){ 2124 struct GNUNET_SCHEDULER_Handle *sh)
2130 2125{
2131 while_live(sh->rs, sh->ws); 2126 return while_live(sh->rs, sh->ws);
2132
2133} 2127}
2134 2128
2129
2135static void 2130static void
2136select_set_wakeup(void *cls, 2131select_set_wakeup(void *cls,
2137 struct GNUNET_TIME_Absolute dt){ 2132 struct GNUNET_TIME_Absolute dt)
2138 2133{
2139
2140 2134
2141} 2135}
2142 2136