~clint-fewbar/ubuntu/precise/php5/php5-5.4-merge

« back to all changes in this revision

Viewing changes to sapi/fpm/fpm/fpm_status.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-02-22 09:46:37 UTC
  • mfrom: (1.1.20) (0.3.18 sid)
  • Revision ID: package-import@ubuntu.com-20110222094637-nlu2tvb7oqgaarl0
Tags: 5.3.5-1ubuntu1
* Merge from debian/unstable. Remaining changes:
 - debian/control:
    * Dropped firebird2.1-dev, libc-client-dev, libmcrypt-dev as it is in universe.
    * Dropped libmysqlclient15-dev, build against mysql 5.1.
    * Dropped libcurl-dev not in the archive.
    * Suggest php5-suhosin rather than recommends.
    * Dropped php5-imap, php5-interbase, php5-mcrypt since we have versions 
      already in universe.
    * Dropped libonig-dev and libqgdbm since its in universe. (will be re-added in lucid+1)
    * Dropped locales-all.
  - modulelist: Drop imap, interbase, sybase, and mcrypt.
  - debian/rules:
    * Dropped building of mcrypt, imap, and interbase.
    * Install apport hook for php5.
    * stop mysql instance on clean just in case we failed in tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
 
        /* $Id: fpm_status.c 298380 2010-04-23 15:09:28Z fat $ */
 
2
        /* $Id: fpm_status.c 305281 2010-11-11 21:38:18Z fat $ */
3
3
        /* (c) 2009 Jerome Loyet */
4
4
 
5
5
#include "php.h"
20
20
int fpm_status_init_child(struct fpm_worker_pool_s *wp) /* {{{ */
21
21
{
22
22
        if (!wp || !wp->config) {
23
 
                zlog(ZLOG_STUFF, ZLOG_ERROR, "unable to init fpm_status because conf structure is NULL");
 
23
                zlog(ZLOG_ERROR, "unable to init fpm_status because conf structure is NULL");
24
24
                return -1;
25
25
        }
26
26
        if (wp->config->pm_status_path || wp->config->ping_path) {
27
27
                if (wp->config->pm_status_path) {
28
28
                        if (!wp->shm_status) {
29
 
                                zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] unable to init fpm_status because the dedicated SHM has not been set", wp->config->name);
 
29
                                zlog(ZLOG_ERROR, "[pool %s] unable to init fpm_status because the dedicated SHM has not been set", wp->config->name);
30
30
                                return -1;
31
31
                        }
32
32
                        fpm_status_shm = wp->shm_status;
37
37
                }
38
38
                if (wp->config->ping_path) {
39
39
                        if (!wp->config->ping_response) {
40
 
                                zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] ping is set (%s) but pong is not set.", wp->config->name, wp->config->ping_path);
 
40
                                zlog(ZLOG_ERROR, "[pool %s] ping is set (%s) but pong is not set.", wp->config->name, wp->config->ping_path);
41
41
                                return -1;
42
42
                        }
43
43
                        fpm_status_ping = strdup(wp->config->ping_path);
99
99
}
100
100
/* }}} */
101
101
 
102
 
void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, int clear_last_update) /* {{{ */
 
102
void fpm_status_increment_max_children_reached(struct fpm_shm_s *shm) /* {{{ */
 
103
{
 
104
        struct fpm_status_s status;
 
105
 
 
106
        if (!shm) shm = fpm_status_shm;
 
107
        if (!shm || !shm->mem) return;
 
108
 
 
109
        /* one shot operation */
 
110
        status = *(struct fpm_status_s *)shm->mem;
 
111
 
 
112
        status.max_children_reached++;
 
113
 
 
114
        /* one shot operation */
 
115
        *(struct fpm_status_s *)shm->mem = status;
 
116
}
 
117
/* }}} */
 
118
 
 
119
void fpm_status_update_max_children_reached(struct fpm_shm_s *shm, unsigned int max_children_reached) /* {{{ */
 
120
{
 
121
        struct fpm_status_s status;
 
122
 
 
123
        if (!shm) shm = fpm_status_shm;
 
124
        if (!shm || !shm->mem) return;
 
125
 
 
126
        /* one shot operation */
 
127
        status = *(struct fpm_status_s *)shm->mem;
 
128
 
 
129
        status.max_children_reached = max_children_reached;
 
130
 
 
131
        /* one shot operation */
 
132
        *(struct fpm_status_s *)shm->mem = status;
 
133
}
 
134
/* }}} */
 
135
 
 
136
void fpm_status_update_activity(struct fpm_shm_s *shm, int idle, int active, int total, unsigned cur_lq, int max_lq, int clear_last_update) /* {{{ */
103
137
{
104
138
        struct fpm_status_s status;
105
139
 
112
146
        status.idle = idle;
113
147
        status.active = active;
114
148
        status.total = total;
 
149
        status.cur_lq = cur_lq;
 
150
        status.max_lq = max_lq;
115
151
        if (clear_last_update) {
116
152
                memset(&status.last_update, 0, sizeof(status.last_update));
117
153
        } else {
130
166
        }
131
167
 
132
168
        spprintf(output, 0, 
133
 
                "accepted conn:   %lu\n"
134
 
                "pool:             %s\n"
135
 
                "process manager:  %s\n"
136
 
                "idle processes:   %d\n"
137
 
                "active processes: %d\n"
138
 
                "total processes:  %d\n",
139
 
                status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total);
 
169
                "pool:                 %s\n"
 
170
                "process manager:      %s\n"
 
171
                "accepted conn:        %lu\n"
 
172
#if HAVE_FPM_LQ
 
173
                "listen queue len:     %u\n"
 
174
                "max listen queue len: %d\n"
 
175
#endif
 
176
                "idle processes:       %d\n"
 
177
                "active processes:     %d\n"
 
178
                "total processes:      %d\n"
 
179
                "max children reached: %u\n",
 
180
                fpm_status_pool,
 
181
                status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
 
182
                status->accepted_conn,
 
183
#if HAVE_FPM_LQ
 
184
                status->cur_lq,
 
185
                status->max_lq,
 
186
#endif
 
187
                status->idle,
 
188
                status->active,
 
189
                status->total,
 
190
                status->max_children_reached);
140
191
 
141
 
        spprintf(content_type, 0, "text/plain");
 
192
        spprintf(content_type, 0, "Content-Type: text/plain");
142
193
}
143
194
/* }}} */
144
195
 
150
201
 
151
202
        spprintf(output, 0, 
152
203
                "<table>\n"
153
 
                "<tr><th>accepted conn</th><td>%lu</td></tr>\n"
154
204
                "<tr><th>pool</th><td>%s</td></tr>\n"
155
205
                "<tr><th>process manager</th><td>%s</td></tr>\n"
 
206
                "<tr><th>accepted conn</th><td>%lu</td></tr>\n"
 
207
#if HAVE_FPM_LQ
 
208
                "<tr><th>listen queue len</th><td>%u</td></tr>\n"
 
209
                "<tr><th>max listen queue len</th><td>%d</td></tr>\n"
 
210
#endif
156
211
                "<tr><th>idle processes</th><td>%d</td></tr>\n"
157
212
                "<tr><th>active processes</th><td>%d</td></tr>\n"
158
213
                "<tr><th>total processes</th><td>%d</td></tr>\n"
 
214
                "<tr><th>max children reached</th><td>%u</td></tr>\n"
159
215
                "</table>",
160
 
                status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total);
 
216
                fpm_status_pool,
 
217
                status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
 
218
                status->accepted_conn,
 
219
#if HAVE_FPM_LQ
 
220
                status->cur_lq,
 
221
                status->max_lq,
 
222
#endif
 
223
                status->idle,
 
224
                status->active,
 
225
                status->total,
 
226
                status->max_children_reached);
161
227
 
162
 
        spprintf(content_type, 0, "text/html");
 
228
        spprintf(content_type, 0, "Content-Type: text/html");
163
229
}
164
230
/* }}} */
165
231
 
171
237
 
172
238
        spprintf(output, 0, 
173
239
                "{"
174
 
                "\"accepted conn\":%lu,"
175
240
                "\"pool\":\"%s\","
176
241
                "\"process manager\":\"%s\","
 
242
                "\"accepted conn\":%lu,"
 
243
#if HAVE_FPM_LQ
 
244
                "\"listen queue len\":%u,"
 
245
                "\"max listen queue len\":%d,"
 
246
#endif
177
247
                "\"idle processes\":%d,"
178
248
                "\"active processes\":%d,"
179
 
                "\"total processes\":%d"
 
249
                "\"total processes\":%d,"
 
250
                "\"max children reached\":%u"
180
251
                "}",
181
 
                status->accepted_conn, fpm_status_pool, status->pm == PM_STYLE_STATIC ? "static" : "dynamic", status->idle, status->active, status->total);
 
252
                fpm_status_pool,
 
253
                status->pm == PM_STYLE_STATIC ? "static" : "dynamic",
 
254
                status->accepted_conn,
 
255
#if HAVE_FPM_LQ
 
256
                status->cur_lq,
 
257
                status->max_lq,
 
258
#endif
 
259
                status->idle,
 
260
                status->active,
 
261
                status->total,
 
262
                status->max_children_reached);
182
263
 
183
 
        spprintf(content_type, 0, "application/jsonrequest");
 
264
        spprintf(content_type, 0, "Content-Type: application/json");
184
265
}
185
266
/* }}} */
186
267
 
226
307
        }
227
308
 
228
309
        if (!*output || !content_type) {
229
 
                zlog(ZLOG_STUFF, ZLOG_ERROR, "[pool %s] unable to allocate status ouput buffer", fpm_status_pool);
 
310
                zlog(ZLOG_ERROR, "[pool %s] unable to allocate status ouput buffer", fpm_status_pool);
230
311
                return 1;
231
312
        }
232
313