Skip to content
This repository
Newer
Older
100644 489 lines (402 sloc) 12.965 kb
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2
3 /* Cherokee
4 *
5 * Authors:
6 * Alvaro Lopez Ortega <alvaro@alobbs.com>
7 *
920e20bc »
2011-01-14 Happy new year!
8 * Copyright (C) 2001-2011 Alvaro Lopez Ortega
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
2c390923 »
2009-01-02 git-svn-id: svn://cherokee-project.com/cherokee/trunk@2660 5dc97367-9…
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
23 */
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
24
603d94ee »
2008-03-16 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1282 5dc97367-9…
25 #include "common-internal.h"
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
26 #include "admin_server.h"
603d94ee »
2008-03-16 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1282 5dc97367-9…
27
d12e63b7 »
2011-10-01 Enhances cherokee_admin_server_reply_kill_source(). It is not finished
28 #include <signal.h>
29
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
30 #include "bind.h"
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
31 #include "server-protected.h"
32 #include "connection-protected.h"
33 #include "connection_info.h"
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
34 #include "source_interpreter.h"
e460d3c8 »
2006-10-07 git-svn-id: svn://cherokee-project.com/cherokee/trunk@426 5dc97367-97…
35 #include "util.h"
36
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
37
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
38 ret_t
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
39 cherokee_admin_server_reply_get_ports (cherokee_handler_t *hdl,
40 cherokee_dwriter_t *dwriter)
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
41 {
dd0a852a »
2008-12-27 git-svn-id: svn://cherokee-project.com/cherokee/trunk@2652 5dc97367-9…
42 cherokee_list_t *i;
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
43 cherokee_bind_t *bind_entry;
44 cherokee_server_t *srv = HANDLER_SRV(hdl);
651edbdf »
2008-05-20 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
45
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
46 cherokee_dwriter_list_open (dwriter);
651edbdf »
2008-05-20 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
47
dd0a852a »
2008-12-27 git-svn-id: svn://cherokee-project.com/cherokee/trunk@2652 5dc97367-9…
48 list_for_each (i, &srv->listeners) {
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
49 bind_entry = BIND(i);
dd0a852a »
2008-12-27 git-svn-id: svn://cherokee-project.com/cherokee/trunk@2652 5dc97367-9…
50
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
51 cherokee_dwriter_dict_open (dwriter);
dd0a852a »
2008-12-27 git-svn-id: svn://cherokee-project.com/cherokee/trunk@2652 5dc97367-9…
52
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
53 cherokee_dwriter_cstring (dwriter, "id");
54 cherokee_dwriter_integer (dwriter, bind_entry->id);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
55
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
56 cherokee_dwriter_cstring (dwriter, "bind");
57 cherokee_dwriter_bstring (dwriter, &bind_entry->ip);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
58
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
59 cherokee_dwriter_cstring (dwriter, "port");
60 cherokee_dwriter_integer (dwriter, bind_entry->port);
651edbdf »
2008-05-20 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
61
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
62 cherokee_dwriter_cstring (dwriter, "tls");
63 cherokee_dwriter_bool (dwriter, BIND_IS_TLS(bind_entry));
651edbdf »
2008-05-20 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
64
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
65 cherokee_dwriter_dict_close (dwriter);
dd0a852a »
2008-12-27 git-svn-id: svn://cherokee-project.com/cherokee/trunk@2652 5dc97367-9…
66 }
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
67 cherokee_dwriter_list_close (dwriter);
651edbdf »
2008-05-20 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
68
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
69 return ret_ok;
70 }
71
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
72 ret_t
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
73 cherokee_admin_server_reply_get_traffic (cherokee_handler_t *hdl,
74 cherokee_dwriter_t *dwriter)
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
75 {
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
76 cherokee_server_t *srv = HANDLER_SRV(hdl);
77 cherokee_buffer_t *tmp = THREAD_TMP_BUF2 (HANDLER_THREAD(hdl));
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
78
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
79 cherokee_dwriter_dict_open (dwriter);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
80
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
81 cherokee_dwriter_cstring (dwriter, "tx");
82 if (srv->collector) {
83 cherokee_dwriter_integer (dwriter, COLLECTOR_TX(srv->collector));
84 } else {
85 cherokee_dwriter_number (dwriter, "-1", 2);
86 }
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
87
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
88 cherokee_dwriter_cstring (dwriter, "rx");
89 if (srv->collector) {
90 cherokee_dwriter_integer (dwriter, COLLECTOR_RX(srv->collector));
91 } else {
92 cherokee_dwriter_number (dwriter, "-1", 2);
93 }
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
94
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
95 cherokee_dwriter_cstring (dwriter, "tx_formatted");
96 if (srv->collector != NULL) {
97 cherokee_buffer_clean (tmp);
98 cherokee_buffer_add_fsize (tmp, COLLECTOR_TX(srv->collector));
99 cherokee_dwriter_bstring (dwriter, tmp);
100 } else {
101 cherokee_dwriter_null (dwriter);
102 }
651edbdf »
2008-05-20 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
103
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
104 cherokee_dwriter_cstring (dwriter, "rx_formatted");
105 if (srv->collector != NULL) {
106 cherokee_buffer_clean (tmp);
107 cherokee_buffer_add_fsize (tmp, COLLECTOR_RX(srv->collector));
108 cherokee_dwriter_bstring (dwriter, tmp);
109 } else {
110 cherokee_dwriter_null (dwriter);
111 }
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
112
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
113 cherokee_dwriter_dict_close (dwriter);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
114 return ret_ok;
115 }
116
117
118 static void
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
119 render_connection_info (cherokee_connection_info_t *conn_info,
120 cherokee_dwriter_t *dwriter)
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
121 {
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
122 cherokee_dwriter_dict_open (dwriter);
123
124 cherokee_dwriter_cstring (dwriter, "id");
125 cherokee_dwriter_bstring (dwriter, &conn_info->id);
126 cherokee_dwriter_cstring (dwriter, "ip");
127 cherokee_dwriter_bstring (dwriter, &conn_info->ip);
128 cherokee_dwriter_cstring (dwriter, "phase");
129 cherokee_dwriter_bstring (dwriter, &conn_info->phase);
130
131 if (! cherokee_buffer_is_empty(&conn_info->rx)) {
132 cherokee_dwriter_cstring (dwriter, "rx");
133 cherokee_dwriter_bstring (dwriter, &conn_info->rx);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
134 }
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
135 if (! cherokee_buffer_is_empty(&conn_info->tx)) {
136 cherokee_dwriter_cstring (dwriter, "tx");
137 cherokee_dwriter_bstring (dwriter, &conn_info->tx);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
138 }
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
139 if (! cherokee_buffer_is_empty(&conn_info->request)) {
140 cherokee_dwriter_cstring (dwriter, "request");
141 cherokee_dwriter_bstring (dwriter, &conn_info->request);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
142 }
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
143 if (! cherokee_buffer_is_empty(&conn_info->handler)) {
144 cherokee_dwriter_cstring (dwriter, "handler");
145 cherokee_dwriter_bstring (dwriter, &conn_info->handler);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
146 }
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
147 if (! cherokee_buffer_is_empty(&conn_info->total_size)) {
148 cherokee_dwriter_cstring (dwriter, "total_size");
149 cherokee_dwriter_bstring (dwriter, &conn_info->total_size);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
150 }
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
151 if (! cherokee_buffer_is_empty(&conn_info->percent)) {
152 cherokee_dwriter_cstring (dwriter, "percent");
153 cherokee_dwriter_bstring (dwriter, &conn_info->percent);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
154 }
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
155 if (! cherokee_buffer_is_empty(&conn_info->icon)) {
156 cherokee_dwriter_cstring (dwriter, "icon");
157 cherokee_dwriter_bstring (dwriter, &conn_info->icon);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
158 }
159
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
160 cherokee_dwriter_dict_close (dwriter);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
161 }
162
163 ret_t
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
164 cherokee_admin_server_reply_get_conns (cherokee_handler_t *hdl,
165 cherokee_dwriter_t *dwriter)
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
166 {
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
167 ret_t ret;
168 cherokee_list_t connections;
169 cherokee_list_t *i, *tmp;
170 cherokee_server_t *srv = HANDLER_SRV(hdl);
651edbdf »
2008-05-20 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
171
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
172 /* Build the connection-info list
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
173 */
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
174 INIT_LIST_HEAD (&connections);
175
176 ret = cherokee_connection_info_list_server (&connections, srv, HANDLER(hdl));
177 if (unlikely (ret == ret_error)) {
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
178 return ret_error;
179 }
180
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
181 /* Render it
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
182 */
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
183 cherokee_dwriter_list_open (dwriter);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
184 list_for_each (i, &connections) {
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
185 cherokee_connection_info_t *conn_info = CONN_INFO(i);
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
186
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
187 /* It won't include details about the admin requests
188 */
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
189 if (! cherokee_buffer_cmp_str (&conn_info->handler, "admin")) {
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
190 continue;
191 }
192
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
193 render_connection_info (conn_info, dwriter);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
194 }
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
195 cherokee_dwriter_list_close (dwriter);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
196
197 /* Free the connection info objects
198 */
199 list_for_each_safe (i, tmp, &connections) {
200 cherokee_connection_info_free (CONN_INFO(i));
201 }
202
203 return ret_ok;
204 }
205
206
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
207 ret_t
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
208 cherokee_admin_server_reply_close_conn (cherokee_handler_t *hdl,
209 cherokee_dwriter_t *dwriter,
210 cherokee_buffer_t *question)
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
211 {
212 ret_t ret;
213 char *begin;
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
214 cherokee_server_t *server = HANDLER_SRV(hdl);
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
215
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
216 if (strncmp (question->buf, "del server.connection ", 22)) {
217 return ret_error;
218 }
219
220 begin = question->buf + 22;
221 ret = cherokee_server_del_connection (server, begin);
222
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
223 cherokee_dwriter_dict_open (dwriter);
224 cherokee_dwriter_cstring (dwriter, "close");
225 cherokee_dwriter_cstring (dwriter, ret == ret_ok ? "ok" : "failed");
226 cherokee_dwriter_dict_close (dwriter);
227
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
228 return ret_ok;
229 }
230
231
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
232 ret_t
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
233 cherokee_admin_server_reply_get_trace (cherokee_handler_t *hdl,
234 cherokee_dwriter_t *dwriter)
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
235 {
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
236 ret_t ret;
237 cherokee_buffer_t *traces_ref = NULL;
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
238
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
239 UNUSED (hdl);
651edbdf »
2008-05-20 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
240
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
241 ret = cherokee_trace_get_trace (&traces_ref);
242 if (ret != ret_ok) {
243 return ret_error;
244 }
245
246 cherokee_dwriter_dict_open (dwriter);
247 cherokee_dwriter_cstring (dwriter, "trace");
248
249 if (cherokee_buffer_is_empty (traces_ref)) {
250 cherokee_dwriter_null (dwriter);
251 } else {
252 cherokee_dwriter_bstring (dwriter, traces_ref);
253 }
254
255 cherokee_dwriter_dict_close (dwriter);
256 return ret_ok;
257 }
258
259 ret_t
260 cherokee_admin_server_reply_set_trace (cherokee_handler_t *hdl,
261 cherokee_dwriter_t *dwriter,
262 cherokee_buffer_t *question)
263 {
264 ret_t ret;
265
266 UNUSED (hdl);
267
268 /* Process question
269 */
270 if (strncmp (question->buf, "set server.trace ", sizeof("set server.trace ")-1)) {
271 return ret_error;
272 }
273 cherokee_buffer_move_to_begin (question, sizeof("set server.trace "-1));
274
275 /* Set the traces
276 */
277 ret = cherokee_trace_set_modules (question);
278 if (ret != ret_ok) {
279 return ret_error;
280 }
281
282 /* Reply
283 */
284 cherokee_dwriter_dict_open (dwriter);
285 cherokee_dwriter_cstring (dwriter, "set");
286 cherokee_dwriter_bool (dwriter, ret == ret_ok);
287 cherokee_dwriter_dict_close (dwriter);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
288 return ret_ok;
289 }
290
291
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
292 ret_t
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
293 cherokee_admin_server_reply_set_backup_mode (cherokee_handler_t *hdl,
294 cherokee_dwriter_t *dwriter,
295 cherokee_buffer_t *question)
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
296 {
297 ret_t ret;
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
298 cherokee_server_t *srv = HANDLER_SRV(hdl);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
299 cherokee_boolean_t active;
300 cherokee_boolean_t mode;
301
302 /* Read if the resquest if for turning it on or off
303 */
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
304 if (cherokee_buffer_cmp_str (question, "set server.backup_mode on") == 0) {
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
305 mode = true;
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
306 } else if (cherokee_buffer_cmp_str (question, "set server.backup_mode off") == 0) {
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
307 mode = false;
308 } else {
309 return ret_error;
310 }
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
311
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
312 /* Do it
313 */
314 ret = cherokee_server_set_backup_mode (srv, mode);
315 if (ret != ret_ok) return ret;
316
317 /* Build the reply
318 */
319 cherokee_server_get_backup_mode (srv, &active);
320
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
321 cherokee_dwriter_dict_open (dwriter);
322 cherokee_dwriter_cstring (dwriter, "backup_mode");
323 cherokee_dwriter_bool (dwriter, mode);
324 cherokee_dwriter_dict_close (dwriter);
ae9d9717 »
2006-04-01 git-svn-id: svn://cherokee-project.com/cherokee/trunk@243 5dc97367-97…
325
326 return ret_ok;
327 }
328
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
329 ret_t
330 cherokee_admin_server_reply_get_thread_num (cherokee_handler_t *hdl,
331 cherokee_dwriter_t *dwriter)
332 {
333 cherokee_server_t *srv = HANDLER_SRV(hdl);
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
334
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
335 cherokee_dwriter_dict_open (dwriter);
336 cherokee_dwriter_cstring (dwriter, "thread_num");
337 cherokee_dwriter_integer (dwriter, srv->thread_num);
338 cherokee_dwriter_dict_close (dwriter);
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
339
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
340 return ret_ok;
341 }
342
343
344 static ret_t
345 sources_while (cherokee_buffer_t *key, void *value, void *param)
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
346 {
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
347 cherokee_dwriter_t *dwriter = DWRITER(param);
348 cherokee_source_t *source = SOURCE(value);
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
349
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
350 cherokee_dwriter_dict_open (dwriter);
651edbdf »
2008-05-20 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
351
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
352 cherokee_dwriter_cstring (dwriter, "id");
353 cherokee_dwriter_bstring (dwriter, key);
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
354
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
355 cherokee_dwriter_cstring (dwriter, "type");
356 switch (source->type) {
357 case source_host:
358 cherokee_dwriter_cstring (dwriter, "host");
359 break;
360 case source_interpreter:
361 cherokee_dwriter_cstring (dwriter, "interpreter");
362 break;
363 default:
364 cherokee_dwriter_dict_close (dwriter);
365 SHOULDNT_HAPPEN;
366 return ret_error;
367 }
368
369 cherokee_dwriter_cstring (dwriter, "bind");
370 cherokee_dwriter_bstring (dwriter, &source->original);
371
372 if (source->type == source_interpreter) {
373 cherokee_source_interpreter_t *source_int = SOURCE_INT(source);
374
375 cherokee_dwriter_cstring (dwriter, "PID");
376 cherokee_dwriter_integer (dwriter, source_int->pid);
377
378 cherokee_dwriter_cstring (dwriter, "debug");
379 cherokee_dwriter_bool (dwriter, source_int->debug);
380
381 cherokee_dwriter_cstring (dwriter, "timeout");
382 cherokee_dwriter_integer (dwriter, source_int->timeout);
383
384 cherokee_dwriter_cstring (dwriter, "interpreter");
385 cherokee_dwriter_bstring (dwriter, &source_int->interpreter);
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
386 }
387
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
388 cherokee_dwriter_dict_close (dwriter);
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
389 return ret_ok;
390 }
391
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
392 ret_t
393 cherokee_admin_server_reply_get_sources (cherokee_handler_t *hdl,
394 cherokee_dwriter_t *dwriter)
395 {
396 cherokee_server_t *srv = HANDLER_SRV(hdl);
397
398 cherokee_dwriter_list_open (dwriter);
399 cherokee_avl_while (&srv->sources, sources_while, dwriter, NULL, NULL);
400 cherokee_dwriter_list_close (dwriter);
401
402 return ret_ok;
403 }
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
404
72f64441 »
2009-12-13 Clean up: Trims trailing spaces.
405 ret_t
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
406 cherokee_admin_server_reply_kill_source (cherokee_handler_t *hdl,
407 cherokee_dwriter_t *dwriter,
408 cherokee_buffer_t *question)
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
409 {
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
410 ret_t ret;
411 char *begin;
d12e63b7 »
2011-10-01 Enhances cherokee_admin_server_reply_kill_source(). It is not finished
412 char *end;
413 char *p;
414 cuint_t n;
415 char id[10];
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
416 cherokee_source_t *source = NULL;
417 cherokee_server_t *srv = HANDLER_SRV(hdl);
418
d12e63b7 »
2011-10-01 Enhances cherokee_admin_server_reply_kill_source(). It is not finished
419 /* Check the command
420 */
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
421 if (strncmp (question->buf, "kill server.source ", sizeof("kill server.source ")-1)) {
422 return ret_error;
423 }
424 begin = question->buf + sizeof("kill server.source ")-1;
d12e63b7 »
2011-10-01 Enhances cherokee_admin_server_reply_kill_source(). It is not finished
425 end = question->buf + question->len;
426
427 /* Check the source to be killed
428 */
429 n = 0;
430 p = begin;
431 while (CHEROKEE_CHAR_IS_DIGIT(*p) && (p < end)) {
432 id[n] = *p;
433 p++;
434 n++;
435 }
436 id[n] = '\0';
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
437
d12e63b7 »
2011-10-01 Enhances cherokee_admin_server_reply_kill_source(). It is not finished
438 if (unlikely ((n <= 0) || (n >= sizeof(n)))) {
439 cherokee_dwriter_dict_open (dwriter);
440 cherokee_dwriter_cstring (dwriter, "source");
441 cherokee_dwriter_cstring (dwriter, "invalid");
442 cherokee_dwriter_dict_close (dwriter);
443 return ret_ok;
444 }
445
446 /* Find it on the AVL tree
447 */
448 ret = cherokee_avl_get_ptr (&srv->sources, id, (void **)&source);
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
449 if (ret != ret_ok) {
450 cherokee_dwriter_dict_open (dwriter);
451 cherokee_dwriter_cstring (dwriter, "source");
452 cherokee_dwriter_cstring (dwriter, "not found");
453 cherokee_dwriter_dict_close (dwriter);
454 return ret_ok;
455 }
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
456
8507a571 »
2011-08-21 Implements an extra check after cherokee_avl_get_ptr where the return…
457 if ((source != NULL) &&
458 ((source->type != source_interpreter) ||
459 ((source->type == source_interpreter) && (SOURCE_INT(source)->pid <= 1))))
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
460 {
461 cherokee_dwriter_dict_open (dwriter);
462 cherokee_dwriter_cstring (dwriter, "source");
463 cherokee_dwriter_cstring (dwriter, "nothing to kill");
464 cherokee_dwriter_dict_close (dwriter);
465 return ret_ok;
466 }
651edbdf »
2008-05-20 git-svn-id: svn://cherokee-project.com/cherokee/trunk@1439 5dc97367-9…
467
d12e63b7 »
2011-10-01 Enhances cherokee_admin_server_reply_kill_source(). It is not finished
468 /* Kill the process
469 */
470 if (getuid() == 0) {
471 /* Looks like we can actully kill the process
472 */
473 kill (SOURCE_INT(source)->pid, SIGTERM);
474 goto ok;
475 } else {
476 /* It should be the 'cherokee' supervisor (running as root)
477 * the one in charge of killing the process.
478 */
479 // TODO
480 }
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
481
d12e63b7 »
2011-10-01 Enhances cherokee_admin_server_reply_kill_source(). It is not finished
482 ok:
197ba3c1 »
2010-08-16 The admin_client classes are not longer needed, so libcherokee-config
483 cherokee_dwriter_dict_open (dwriter);
484 cherokee_dwriter_cstring (dwriter, "source");
485 cherokee_dwriter_cstring (dwriter, "killed");
486 cherokee_dwriter_dict_close (dwriter);
eb566f9f »
2007-12-04 git-svn-id: svn://cherokee-project.com/cherokee/trunk@948 5dc97367-97…
487 return ret_ok;
488 }
Something went wrong with that request. Please try again.