Merge lp:~brianaker/gearmand/1196552 into lp:gearmand

Proposed by Brian Aker on 2013-08-11
Status: Merged
Merged at revision: 854
Proposed branch: lp:~brianaker/gearmand/1196552
Merge into: lp:gearmand
Diff against target: 168 lines (+60/-11)
6 files modified
libgearman-server/gearmand_con.cc (+37/-5)
libgearman-server/gearmand_con.h (+4/-3)
libgearman-server/job.cc (+1/-2)
libgearman-server/text.cc (+7/-1)
libtest/client.hpp (+5/-0)
util/instance.hpp (+6/-0)
To merge this branch: bzr merge lp:~brianaker/gearmand/1196552
Reviewer Review Type Date Requested Status
Tangent Trunk 2013-08-11 Pending
Review via email: mp+179592@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libgearman-server/gearmand_con.cc'
2--- libgearman-server/gearmand_con.cc 2013-07-22 21:18:42 +0000
3+++ libgearman-server/gearmand_con.cc 2013-08-11 02:45:20 +0000
4@@ -44,6 +44,7 @@
5 #include "gear_config.h"
6 #include "libgearman-server/common.h"
7 #include <libgearman-server/gearmand.h>
8+#include <libgearman-server/queue.h>
9 #include <cstring>
10
11 #include <cerrno>
12@@ -253,10 +254,11 @@
13 return NULL;
14 }
15
16-bool gearman_server_job_cancel(gearman_server_st& server,
17- const char *job_handle,
18- const size_t job_handle_length)
19+gearmand_error_t gearman_server_job_cancel(gearman_server_st& server,
20+ const char *job_handle,
21+ const size_t job_handle_length)
22 {
23+ gearmand_error_t ret= GEARMAND_NO_JOBS;
24 uint32_t key= _server_job_hash(job_handle, job_handle_length);
25
26 gearmand_log_debug(GEARMAN_DEFAULT_LOG_PARAM, "cancel: %.*s", int(job_handle_length), job_handle);
27@@ -268,14 +270,44 @@
28 if (server_job->job_handle_key == key and
29 strncmp(server_job->job_handle, job_handle, GEARMAND_JOB_HANDLE_SIZE) == 0)
30 {
31+ /* Queue the fail packet for all clients. */
32+ for (gearman_server_client_st* client= server_job->client_list; client != NULL; client= client->job_next)
33+ {
34+ ret= gearman_server_io_packet_add(client->con, false,
35+ GEARMAN_MAGIC_RESPONSE,
36+ GEARMAN_COMMAND_WORK_FAIL,
37+ server_job->job_handle,
38+ (size_t)strlen(server_job->job_handle),
39+ NULL);
40+ if (gearmand_failed(ret))
41+ {
42+ gearmand_log_gerror_warn(GEARMAN_DEFAULT_LOG_PARAM, ret, "Failed to send WORK_FAIL packet to %s:%s", client->con->host(), client->con->port());
43+ }
44+ }
45+
46+ /* Remove from persistent queue if one exists. */
47+ if (server_job->job_queued)
48+ {
49+ ret= gearman_queue_done(Server,
50+ server_job->unique,
51+ server_job->unique_length,
52+ server_job->function->function_name,
53+ server_job->function->function_name_size);
54+ if (gearmand_failed(ret))
55+ {
56+ gearmand_gerror("Remove from persistent queue", ret);
57+ return ret;
58+ }
59+ }
60+
61 server_job->ignore_job= true;
62 server_job->job_queued= false;
63
64- return true;
65+ return GEARMAND_SUCCESS;
66 }
67 }
68
69- return false;
70+ return ret;
71 }
72
73 gearman_server_job_st * gearman_server_job_peek(gearman_server_con_st *server_con)
74
75=== modified file 'libgearman-server/gearmand_con.h'
76--- libgearman-server/gearmand_con.h 2013-07-07 00:16:26 +0000
77+++ libgearman-server/gearmand_con.h 2013-08-11 02:45:20 +0000
78@@ -78,9 +78,10 @@
79 const char *host, const char*,
80 struct gearmand_port_st*);
81
82-bool gearman_server_job_cancel(gearman_server_st& server,
83- const char *job_handle,
84- const size_t job_handle_length);
85+GEARMAN_API
86+gearmand_error_t gearman_server_job_cancel(gearman_server_st& server,
87+ const char *job_handle,
88+ const size_t job_handle_length);
89
90 /**
91 * Free resources used by a connection.
92
93=== modified file 'libgearman-server/job.cc'
94--- libgearman-server/job.cc 2013-08-07 22:23:36 +0000
95+++ libgearman-server/job.cc 2013-08-11 02:45:20 +0000
96@@ -403,8 +403,7 @@
97 GEARMAN_COMMAND_NOOP, NULL);
98 if (gearmand_failed(ret))
99 {
100- gearmand_gerror("gearman_server_io_packet_add", ret);
101- return ret;
102+ gearmand_log_gerror_warn(GEARMAN_DEFAULT_LOG_PARAM, ret, "Failed to send NOOP packet to %s:%s", worker->con->host(), worker->con->port());
103 }
104
105 worker->con->is_noop_sent= true;
106
107=== modified file 'libgearman-server/text.cc'
108--- libgearman-server/text.cc 2013-07-22 21:18:42 +0000
109+++ libgearman-server/text.cc 2013-08-11 02:45:20 +0000
110@@ -144,10 +144,16 @@
111 if (packet->argc == 3
112 and strcasecmp("job", (char *)(packet->arg[1])) == 0)
113 {
114- if (gearman_server_job_cancel(Gearmand()->server, packet->arg[2], strlen(packet->arg[2])))
115+ gearmand_error_t ret= gearman_server_job_cancel(Gearmand()->server, packet->arg[2], strlen(packet->arg[2]));
116+
117+ if (ret == GEARMAND_SUCCESS)
118 {
119 data.vec_printf(TEXT_SUCCESS);
120 }
121+ else if (ret != GEARMAND_NO_JOBS)
122+ {
123+ data.vec_printf(TEXT_ERROR_INTERNAL_ERROR);
124+ }
125 else
126 {
127 data.vec_printf(TEXT_ERROR_UNKNOWN_JOB);
128
129=== modified file 'libtest/client.hpp'
130--- libtest/client.hpp 2013-08-07 22:23:36 +0000
131+++ libtest/client.hpp 2013-08-11 02:45:20 +0000
132@@ -38,6 +38,10 @@
133
134 #include "libgearman/ssl.h"
135
136+#pragma GCC diagnostic push
137+#pragma GCC diagnostic ignored "-Wpragmas"
138+#pragma GCC diagnostic ignored "-Wunused-private-field"
139+
140 namespace libtest {
141
142 class SimpleClient {
143@@ -107,3 +111,4 @@
144 };
145
146 } // namespace libtest
147+#pragma GCC diagnostic pop
148
149=== modified file 'util/instance.hpp'
150--- util/instance.hpp 2013-08-07 22:23:36 +0000
151+++ util/instance.hpp 2013-08-11 02:45:20 +0000
152@@ -52,6 +52,10 @@
153
154 struct addrinfo;
155
156+#pragma GCC diagnostic push
157+#pragma GCC diagnostic ignored "-Wpragmas"
158+#pragma GCC diagnostic ignored "-Wunused-private-field"
159+
160 namespace datadifferential {
161 namespace util {
162
163@@ -163,3 +167,5 @@
164
165 } /* namespace util */
166 } /* namespace datadifferential */
167+
168+#pragma GCC diagnostic pop

Subscribers

People subscribed via source and target branches

to all changes: