diff options
author | LRN <lrn1986@gmail.com> | 2013-03-13 17:49:26 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2013-03-13 17:49:26 +0000 |
commit | 405f776bc08486af4edb80e18149c0829732b347 (patch) | |
tree | d5fc635a51641dec6b53cb2540276f34ae8f6210 /src/regex | |
parent | 3ceae682287492ecc768aea5c4c463216a35774d (diff) | |
download | gnunet-405f776bc08486af4edb80e18149c0829732b347.tar.gz gnunet-405f776bc08486af4edb80e18149c0829732b347.zip |
All-encompassing ARM update
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-regex-profiler.c | 147 | ||||
-rw-r--r-- | src/regex/regex_test_lib.c | 2 |
2 files changed, 54 insertions, 95 deletions
diff --git a/src/regex/gnunet-regex-profiler.c b/src/regex/gnunet-regex-profiler.c index 0c104fab4..303f1fffc 100644 --- a/src/regex/gnunet-regex-profiler.c +++ b/src/regex/gnunet-regex-profiler.c | |||
@@ -997,6 +997,17 @@ find_next_string (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
997 | } | 997 | } |
998 | 998 | ||
999 | 999 | ||
1000 | |||
1001 | /** | ||
1002 | * Start announcing the next regex in the DHT. | ||
1003 | * | ||
1004 | * @param cls Index of the next peer in the peers array. | ||
1005 | * @param tc TaskContext. | ||
1006 | */ | ||
1007 | void | ||
1008 | announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
1009 | |||
1010 | |||
1000 | /** | 1011 | /** |
1001 | * ARM connect adapter. Opens a connection to the ARM service. | 1012 | * ARM connect adapter. Opens a connection to the ARM service. |
1002 | * | 1013 | * |
@@ -1010,7 +1021,8 @@ arm_ca (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
1010 | { | 1021 | { |
1011 | struct RegexPeer *peer = cls; | 1022 | struct RegexPeer *peer = cls; |
1012 | 1023 | ||
1013 | peer->arm_handle = GNUNET_ARM_connect (cfg, NULL); | 1024 | peer->arm_handle = GNUNET_ARM_alloc (cfg); |
1025 | GNUNET_ARM_connect (peer->arm_handle, NULL, NULL); | ||
1014 | 1026 | ||
1015 | return peer->arm_handle; | 1027 | return peer->arm_handle; |
1016 | } | 1028 | } |
@@ -1036,104 +1048,52 @@ arm_da (void *cls, void *op_result) | |||
1036 | } | 1048 | } |
1037 | } | 1049 | } |
1038 | 1050 | ||
1039 | |||
1040 | /** | ||
1041 | * Start announcing the next regex in the DHT. | ||
1042 | * | ||
1043 | * @param cls Index of the next peer in the peers array. | ||
1044 | * @param tc TaskContext. | ||
1045 | */ | ||
1046 | void | ||
1047 | announce_next_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
1048 | |||
1049 | |||
1050 | /** | ||
1051 | * Callback function invoked when ARM peration is complete: deamon is started. | ||
1052 | * | ||
1053 | * @param cls Closure (RegexPeer). | ||
1054 | * @param result Outcome of the operation. | ||
1055 | */ | ||
1056 | static void | 1051 | static void |
1057 | arm_start_cb (void *cls, enum GNUNET_ARM_ProcessStatus result) | 1052 | regexprofiler_start_cb (void *cls, struct GNUNET_ARM_Handle *arm, |
1053 | enum GNUNET_ARM_RequestStatus rs, const char *service, | ||
1054 | enum GNUNET_ARM_Result result) | ||
1058 | { | 1055 | { |
1059 | struct RegexPeer *peer = (struct RegexPeer *) cls; | 1056 | struct RegexPeer *peer = (struct RegexPeer *) cls; |
1060 | static unsigned int peer_cnt; | ||
1061 | unsigned int next_p; | 1057 | unsigned int next_p; |
1062 | 1058 | ||
1063 | switch (result) | 1059 | if (rs != GNUNET_ARM_REQUEST_SENT_OK) |
1064 | { | 1060 | { |
1065 | /** | 1061 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "ARM request was not sent: %u\n", rs); |
1066 | * Service is currently being started (due to client request). | 1062 | GNUNET_abort (); |
1067 | */ | 1063 | } |
1068 | case GNUNET_ARM_PROCESS_STARTING: | 1064 | else if (result != GNUNET_ARM_RESULT_STARTING) |
1069 | GNUNET_TESTBED_operation_done (peer->op_handle); | 1065 | { |
1070 | peer->op_handle = NULL; | 1066 | /* FIXME: maybe check for other acceptable results (already starting, |
1071 | 1067 | * already started)? | |
1072 | if (peer_cnt < (num_peers - 1)) | 1068 | */ |
1073 | { | 1069 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "ARM failed to start regexprofiler: %u\n", result); |
1074 | next_p = (++peer_cnt % num_peers); | 1070 | GNUNET_abort (); |
1075 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply( | 1071 | } |
1076 | GNUNET_TIME_UNIT_MILLISECONDS, | 1072 | GNUNET_TESTBED_operation_done (peer->op_handle); |
1077 | 400), | 1073 | peer->op_handle = NULL; |
1078 | &announce_next_regex, | ||
1079 | (void *) (long) next_p); | ||
1080 | } | ||
1081 | else | ||
1082 | { | ||
1083 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1084 | "All daemons started." | ||
1085 | " Waiting %s to start string searches\n", | ||
1086 | GNUNET_STRINGS_relative_time_to_string (search_delay, | ||
1087 | GNUNET_NO)); | ||
1088 | GNUNET_SCHEDULER_add_delayed (search_delay, | ||
1089 | do_connect_by_string, | ||
1090 | NULL); | ||
1091 | } | ||
1092 | break; | ||
1093 | 1074 | ||
1094 | /** | 1075 | if (peer_cnt < (num_peers - 1)) |
1095 | * Service name is unknown to ARM. | 1076 | { |
1096 | */ | 1077 | next_p = (++peer_cnt % num_peers); |
1097 | case GNUNET_ARM_PROCESS_UNKNOWN: | 1078 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply( |
1098 | /** | 1079 | GNUNET_TIME_UNIT_MILLISECONDS, |
1099 | * Service is now down (due to client request). | 1080 | 400), |
1100 | */ | 1081 | &announce_next_regex, |
1101 | case GNUNET_ARM_PROCESS_DOWN: | 1082 | (void *) (long) next_p); |
1102 | /** | 1083 | } |
1103 | * Service is already running. | 1084 | else |
1104 | */ | 1085 | { |
1105 | case GNUNET_ARM_PROCESS_ALREADY_RUNNING: | 1086 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1106 | /** | 1087 | "All daemons started." |
1107 | * Service is already being stopped by some other client. | 1088 | " Waiting %s to start string searches\n", |
1108 | */ | 1089 | GNUNET_STRINGS_relative_time_to_string (search_delay, |
1109 | case GNUNET_ARM_PROCESS_ALREADY_STOPPING: | 1090 | GNUNET_NO)); |
1110 | /** | 1091 | GNUNET_SCHEDULER_add_delayed (search_delay, |
1111 | * Service is already down (no action taken) | 1092 | do_connect_by_string, |
1112 | */ | 1093 | NULL); |
1113 | case GNUNET_ARM_PROCESS_ALREADY_DOWN: | ||
1114 | /** | ||
1115 | * ARM is currently being shut down (no more process starts) | ||
1116 | */ | ||
1117 | case GNUNET_ARM_PROCESS_SHUTDOWN: | ||
1118 | /** | ||
1119 | * Error in communication with ARM | ||
1120 | */ | ||
1121 | case GNUNET_ARM_PROCESS_COMMUNICATION_ERROR: | ||
1122 | /** | ||
1123 | * Timeout in communication with ARM | ||
1124 | */ | ||
1125 | case GNUNET_ARM_PROCESS_COMMUNICATION_TIMEOUT: | ||
1126 | /** | ||
1127 | * Failure to perform operation | ||
1128 | */ | ||
1129 | case GNUNET_ARM_PROCESS_FAILURE: | ||
1130 | default: | ||
1131 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "ARM returned %d\n", result); | ||
1132 | GNUNET_abort (); | ||
1133 | } | 1094 | } |
1134 | } | 1095 | } |
1135 | 1096 | ||
1136 | |||
1137 | /** | 1097 | /** |
1138 | * ARM connect callback. Called when we are connected to the arm service for | 1098 | * ARM connect callback. Called when we are connected to the arm service for |
1139 | * the peer in 'cls'. If successfull we start the regex deamon to start | 1099 | * the peer in 'cls'. If successfull we start the regex deamon to start |
@@ -1160,11 +1120,10 @@ arm_connect_cb (void *cls, struct GNUNET_TESTBED_Operation *op, | |||
1160 | GNUNET_assert (peer->op_handle == op); | 1120 | GNUNET_assert (peer->op_handle == op); |
1161 | GNUNET_assert (peer->arm_handle == ca_result); | 1121 | GNUNET_assert (peer->arm_handle == ca_result); |
1162 | 1122 | ||
1163 | GNUNET_ARM_start_service (ca_result, "regexprofiler", | 1123 | GNUNET_ARM_request_service_start (ca_result, "regexprofiler", |
1164 | GNUNET_OS_INHERIT_STD_NONE, | 1124 | GNUNET_OS_INHERIT_STD_NONE, |
1165 | GNUNET_TIME_UNIT_FOREVER_REL, | 1125 | GNUNET_TIME_UNIT_FOREVER_REL, |
1166 | &arm_start_cb, | 1126 | regexprofiler_start_cb, cls); |
1167 | peer); | ||
1168 | } | 1127 | } |
1169 | 1128 | ||
1170 | 1129 | ||
diff --git a/src/regex/regex_test_lib.c b/src/regex/regex_test_lib.c index 57c6b13e8..56ccb3496 100644 --- a/src/regex/regex_test_lib.c +++ b/src/regex/regex_test_lib.c | |||
@@ -267,7 +267,7 @@ GNUNET_REGEX_read_from_file (const char *filename) | |||
267 | struct GNUNET_DISK_FileHandle *f; | 267 | struct GNUNET_DISK_FileHandle *f; |
268 | unsigned int nr; | 268 | unsigned int nr; |
269 | unsigned int offset; | 269 | unsigned int offset; |
270 | off_t size; | 270 | uint64_t size; |
271 | size_t len; | 271 | size_t len; |
272 | char *buffer; | 272 | char *buffer; |
273 | char *regex; | 273 | char *regex; |