~ubuntu-branches/ubuntu/oneiric/firebird2.1/oneiric

« back to all changes in this revision

Viewing changes to .pc/frmgr-corrent-log-path.patch/src/utilities/ibmgr/srvrmgr.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Damyan Ivanov
  • Date: 2011-04-22 18:59:44 UTC
  • mfrom: (2.1.24 sid)
  • Revision ID: james.westby@ubuntu.com-20110422185944-egwy9r5xynjddku5
Tags: 2.1.4.18393-0.ds2-2
* apply patch from upstream SVN fixing ICU collations
* remove lintian overrides about manpages shipped in dependency package
* claim compliancy with Policy 3.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *
 
3
 *      PROGRAM:        Firebird server manager
 
4
 *      MODULE:         ibmgr.cpp
 
5
 *      DESCRIPTION:    server manager's routines
 
6
 *
 
7
 * The contents of this file are subject to the Interbase Public
 
8
 * License Version 1.0 (the "License"); you may not use this file
 
9
 * except in compliance with the License. You may obtain a copy
 
10
 * of the License at http://www.Inprise.com/IPL.html
 
11
 *
 
12
 * Software distributed under the License is distributed on an
 
13
 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
 
14
 * or implied. See the License for the specific language governing
 
15
 * rights and limitations under the License.
 
16
 *
 
17
 * The Original Code was created by Inprise Corporation
 
18
 * and its predecessors. Portions created by Inprise Corporation are
 
19
 * Copyright (C) Inprise Corporation.
 
20
 *
 
21
 * All Rights Reserved.
 
22
 * Contributor(s): ______________________________________.
 
23
 */
 
24
 
 
25
#include "firebird.h"
 
26
#ifdef SOLARIS_MT
 
27
#include <thread.h>
 
28
#endif
 
29
 
 
30
#include <stdio.h>
 
31
#include <stdlib.h>
 
32
#include <string.h>
 
33
#include <errno.h>
 
34
#ifdef HAVE_UNISTD_H
 
35
#include <unistd.h>
 
36
#endif
 
37
#include <sys/types.h>
 
38
#if HAVE_SYS_WAIT_H
 
39
# include <sys/wait.h>
 
40
#endif
 
41
 
 
42
 
 
43
#include "../jrd/common.h"
 
44
#include "../jrd/ibase.h"
 
45
#include "../jrd/gds_proto.h"
 
46
#include "../jrd/gdsassert.h"
 
47
#include "../jrd/svc_undoc.h"
 
48
#include "../common/stuff.h"
 
49
#include "../utilities/ibmgr/ibmgr.h"
 
50
#include "../utilities/ibmgr/srvrmgr_proto.h"
 
51
 
 
52
const int SPB_BUFLEN            = 128;  /* service params buffer length */
 
53
//#define SEND_BUFLEN             32    /* length of send and resp */
 
54
//#define RESP_BUFLEN             128   /* used by isc_service_query */
 
55
 
 
56
/* After we fork and exec a guardian process, to determine
 
57
   if the server have started we wait ATTACH_PAUSE seconds
 
58
   and try to attach to it. This happens ATTACH_RETRY number
 
59
   of times
 
60
*/
 
61
const int ATTACH_PAUSE          = 1;    /* seconds to pause before attach */
 
62
const int ATTACH_RETRY          = 10;   /* Number of attach retries */
 
63
 
 
64
 
 
65
static bool attach_service(ibmgr_data_t*);
 
66
static bool detach_service(ibmgr_data_t*);
 
67
static bool print_pool(ibmgr_data_t*);
 
68
static bool start_shutdown(ibmgr_data_t*);
 
69
static bool start_server(ibmgr_data_t*);
 
70
#ifdef NOT_USED_OR_REPLACED
 
71
static bool server_is_ok(ibmgr_data_t*);
 
72
#endif
 
73
static bool server_is_up(ibmgr_data_t*);
 
74
 
 
75
void SRVRMGR_cleanup( ibmgr_data_t* data)
 
76
{
 
77
/**************************************
 
78
 *
 
79
 *      S R V R M G R _ c l e a n u p
 
80
 *
 
81
 **************************************
 
82
 *
 
83
 * Functional description
 
84
 *      If we are attached to a service, detaches
 
85
 *
 
86
 **************************************/
 
87
        if (data->attached)
 
88
                detach_service(data);
 
89
}
 
90
 
 
91
 
 
92
USHORT SRVRMGR_exec_line(ibmgr_data_t* data)
 
93
{
 
94
/**************************************
 
95
 *
 
96
 *      S R V R M G R _ e x e c _ l i n e
 
97
 *
 
98
 **************************************
 
99
 *
 
100
 * Functional description
 
101
 *      Executes command line
 
102
 *
 
103
 **************************************/
 
104
        fb_assert(data->attached || data->reattach);
 
105
 
 
106
/* If reattach is true and we currently attached, then we
 
107
   will detach from service. This is potentially dangerous
 
108
   situation, because if shutdown is true (server shutdown 
 
109
   was initiated) server will be shutdowned.
 
110
   I do not check the shutdown flag here because reattach
 
111
   could be true only if shutdown has not been initiated.
 
112
*/
 
113
        if (data->operation != OP_START)
 
114
                if (data->reattach) {
 
115
                        fb_assert(!data->shutdown);
 
116
                        if (data->attached)
 
117
 
 
118
                                /* Attached flag should be NULL after detach_service
 
119
                                 */
 
120
                                detach_service(data);
 
121
                        if (attach_service(data) == false)
 
122
                                return MSG_ATTFAIL;
 
123
                        data->reattach = 0;
 
124
                }
 
125
 
 
126
        switch (data->operation) {
 
127
        case OP_START:
 
128
                if (start_server(data) == false)
 
129
                        return MSG_STARTFAIL;
 
130
                break;
 
131
 
 
132
        case OP_SHUT:
 
133
                switch (data->suboperation) {
 
134
                case SOP_NONE:
 
135
                case SOP_SHUT_NOW:
 
136
                        data->shutdown = true;
 
137
                        if (start_shutdown(data) == false) {
 
138
                                data->shutdown = false;
 
139
                                return MSG_SSHUTFAIL;
 
140
                        }
 
141
                        detach_service(data);
 
142
                        data->shutdown = false;
 
143
                        data->reattach |= (REA_HOST | REA_USER | REA_PASSWORD);
 
144
                        return MSG_SHUTOK;
 
145
 
 
146
                case SOP_SHUT_NOAT:
 
147
                        printf("SHUTDOWN NO ATTACHMENTS\n");
 
148
                        data->shutdown = true;
 
149
                        break;
 
150
 
 
151
                case SOP_SHUT_NOTR:
 
152
                        printf("SHUTDOWN NO TRANSACTIONS\n");
 
153
                        data->shutdown = true;
 
154
                        break;
 
155
 
 
156
                case SOP_SHUT_IGN:
 
157
                        printf("SHUTDOWN IGNORE\n");
 
158
                        data->shutdown = false;
 
159
                        break;
 
160
                }
 
161
                break;
 
162
 
 
163
        case OP_PRINT:
 
164
                switch (data->suboperation) {
 
165
                case SOP_PRINT_POOL:
 
166
                        if (print_pool(data) == false)
 
167
                                return MSG_PRPOOLFAIL;
 
168
                        return MSG_PRPOOLOK;
 
169
                }
 
170
                break;
 
171
 
 
172
        default:
 
173
#ifdef DEV_BUILD
 
174
                fprintf(OUTFILE,
 
175
                                   "ASSERT: file %s line %"LINEFORMAT": unknown operation %d\n",
 
176
                                   __FILE__, __LINE__, data->operation);
 
177
#endif
 
178
                ;
 
179
        }
 
180
 
 
181
        return FB_SUCCESS;
 
182
}
 
183
 
 
184
 
 
185
void SRVRMGR_msg_get( USHORT number, TEXT * msg)
 
186
{
 
187
/**************************************
 
188
 *
 
189
 *      S R V R M G R _ m s g _ g e t
 
190
 *
 
191
 **************************************
 
192
 *
 
193
 * Functional description
 
194
 *      Retrieve a message from the error file
 
195
 *
 
196
 **************************************/
 
197
 
 
198
/* The following line will be the future of this function
 
199
 
 
200
        static const SafeArg arg;
 
201
        fb_msg_format (0, MSG_FAC, number, MSG_LEN, msg, arg);
 
202
 
 
203
*/
 
204
 
 
205
        const char* rs = 0;
 
206
        
 
207
        switch (number) {
 
208
        case MSG_PROMPT:
 
209
                rs = "FBMGR>";
 
210
                break;
 
211
        case MSG_OPSPEC:
 
212
                rs = "operation already specified";
 
213
                break;
 
214
        case MSG_NOOPSPEC:
 
215
                rs = "no operation specified";
 
216
                break;
 
217
        case MSG_INVSWOP:
 
218
                rs = "illegal operation/switch combination";
 
219
                break;
 
220
        case MSG_SHUTDOWN:
 
221
                rs = "warning: shutdown is in progress";
 
222
                break;
 
223
        case MSG_CANTCHANGE:
 
224
                rs = "can not change host, password or user";
 
225
                break;
 
226
        case MSG_VERSION:
 
227
                rs = "fbmgr version";
 
228
                break;
 
229
        case MSG_INVSW:
 
230
                rs = "invalid switch";
 
231
                break;
 
232
        case MSG_AMBSW:
 
233
                rs = "ambiguous switch";
 
234
                break;
 
235
        case MSG_INVSWSW:
 
236
                rs = "invalid switch combination";
 
237
                break;
 
238
        case MSG_WARNPASS:
 
239
                rs = "warning: only 8 significant bytes of password used";
 
240
                break;
 
241
        case MSG_INVUSER:
 
242
                rs = "invalid user (only 32 bytes allowed";
 
243
                break;
 
244
        case MSG_INVPAR:
 
245
                rs = "invalid parameter, no switch specified";
 
246
                break;
 
247
        case MSG_SWNOPAR:
 
248
                rs = "switch does not take any parameter";
 
249
                break;
 
250
        case MSG_REQPAR:
 
251
                rs = "switch requires parameter";
 
252
                break;
 
253
        case MSG_SYNTAX:
 
254
                rs = "syntax error in command line";
 
255
                break;
 
256
        case MSG_GETPWFAIL:
 
257
                rs = "can not get password entry";
 
258
                break;
 
259
        case MSG_ATTFAIL:
 
260
                rs = "can not attach to server";
 
261
                break;
 
262
        case MSG_CANTSHUT:
 
263
                rs = "can not start another shutdown";
 
264
                break;
 
265
        case MSG_SSHUTFAIL:
 
266
                rs = "can not start server shutdown";
 
267
                break;
 
268
        case MSG_SHUTOK:
 
269
                rs = "server shutdown completed";
 
270
                break;
 
271
        case MSG_CANTQUIT:
 
272
                rs = "can not quit now, use shut -ign";
 
273
                break;
 
274
        case MSG_STARTERR:
 
275
                rs = "check $FIREBIRD/firebird.log file for errors";
 
276
                break;
 
277
        case MSG_STARTFAIL:
 
278
                rs = "can not start server";
 
279
                break;
 
280
        case MSG_SRVUP:
 
281
                rs = "server is already running";
 
282
                break;
 
283
        case MSG_SRVUPOK:
 
284
                rs = "server has been successfully started";
 
285
                break;
 
286
        case MSG_NOPERM:
 
287
                rs = "no permissions to perform operation";
 
288
                break;
 
289
        case MSG_PRPOOLFAIL:
 
290
                rs = "Failed to print pool info";
 
291
                break;
 
292
        case MSG_PRPOOLOK:
 
293
                rs = "Print pool Successfull";
 
294
                break;
 
295
        case MSG_FLNMTOOLONG:
 
296
                rs = "File name too long";
 
297
                break;
 
298
        default:
 
299
                rs = "can not get an error message";
 
300
        }
 
301
        
 
302
        strcpy(msg, rs);
 
303
}
 
304
 
 
305
 
 
306
static bool attach_service( ibmgr_data_t* data)
 
307
{
 
308
/**************************************
 
309
 *
 
310
 *      a t t a c h _ s e r v i c e
 
311
 *
 
312
 **************************************
 
313
 *
 
314
 * Functional description
 
315
 *      Attaches to "anonymous" or "query_server"
 
316
 *      service depending on thr user name.
 
317
 *
 
318
 **************************************/
 
319
        ISC_STATUS_ARRAY status;
 
320
        TEXT svc_name[128];
 
321
 
 
322
/* Obviously we should not be already attached to service
 
323
*/
 
324
        fb_assert(!data->attached);
 
325
 
 
326
        strcpy(svc_name, data->host);
 
327
 
 
328
        TEXT spb[SPB_BUFLEN];
 
329
        TEXT* p = spb;
 
330
 
 
331
        if (!strcmp(data->user, SYSDBA_USER_NAME)) {
 
332
                *p++ = isc_spb_version1;
 
333
                *p++ = isc_spb_user_name;
 
334
                *p++ = strlen(SYSDBA_USER_NAME);
 
335
                strcpy(p, SYSDBA_USER_NAME);
 
336
                p += strlen(p);
 
337
                *p++ = isc_spb_password;
 
338
                *p++ = strlen(data->password);
 
339
                strcpy(p, data->password);
 
340
 
 
341
                strcat(svc_name, ":query_server");
 
342
 
 
343
#ifdef DEBUG
 
344
                fprintf(OUTFILE, "spb: \"%s\"\nsvc_name: \"%s\"\n", spb, svc_name);
 
345
#endif
 
346
 
 
347
                isc_service_attach(status, 0, svc_name, &data->attached, strlen(spb),
 
348
                                                   spb);
 
349
        }
 
350
        else {
 
351
                strcat(svc_name, ":anonymous");
 
352
                isc_service_attach(status, 0, svc_name, &data->attached, 0, "");
 
353
        }
 
354
 
 
355
        if (status[0] == 1 && status[1] > 0) {
 
356
#ifdef DEBUG
 
357
                fprintf(OUTFILE, "ERROR: %lu\n", status[1]);
 
358
#endif
 
359
                fb_assert(status[1] != isc_svcnotdef);
 
360
                isc_print_status(status);
 
361
                return false;
 
362
        }
 
363
        return true;
 
364
}
 
365
 
 
366
 
 
367
static bool detach_service( ibmgr_data_t* data)
 
368
{
 
369
/**************************************
 
370
 *
 
371
 *      d e t a c h _ s e r v i c e
 
372
 *
 
373
 **************************************
 
374
 *
 
375
 * Functional description
 
376
 *      Detaches from service.
 
377
 *      If IBMGR_shutdown_start was called
 
378
 *      before, shutdowns the server.
 
379
 *
 
380
 **************************************/
 
381
        ISC_STATUS_ARRAY status;
 
382
 
 
383
/* We should be attached if we want to detach
 
384
*/
 
385
        fb_assert(data->attached);
 
386
 
 
387
        isc_service_detach(status, &data->attached);
 
388
        data->attached = 0;
 
389
 
 
390
        if (status[0] == 1 && status[1] > 0) {
 
391
/* If as a result of detach_service server has been
 
392
   shutdowned we will get an error.
 
393
   MMM - need to check for that error and return true
 
394
*/
 
395
#ifdef DEBUG
 
396
                fprintf(OUTFILE, "ERROR: %lu\n", status[1]);
 
397
#endif
 
398
                if (!data->shutdown)
 
399
                        isc_print_status(status);
 
400
                return false;
 
401
        }
 
402
        return true;
 
403
}
 
404
 
 
405
 
 
406
static bool start_shutdown( ibmgr_data_t* data)
 
407
{
 
408
/**************************************
 
409
 *
 
410
 *      s t a r t _ s h u t d o w n
 
411
 *
 
412
 **************************************
 
413
 *
 
414
 * Functional description
 
415
 *      Initiate shutdown process
 
416
 *
 
417
 **************************************/
 
418
        ISC_STATUS_ARRAY status;
 
419
        char respbuf[2];
 
420
 
 
421
/* We should be attached to ask for any service
 
422
*/
 
423
        fb_assert(data->attached);
 
424
 
 
425
        const char sendbuf[] = { isc_info_svc_svr_offline };
 
426
        isc_service_query(status, &data->attached, 0, 0, NULL,
 
427
                                          1, sendbuf, sizeof(respbuf), respbuf);
 
428
 
 
429
        if (status[0] == 1 && status[1] > 0) {
 
430
                isc_print_status(status);
 
431
                return false;
 
432
        }
 
433
        return true;
 
434
}
 
435
 
 
436
 
 
437
static bool start_server( ibmgr_data_t* data)
 
438
{
 
439
/**************************************
 
440
 *
 
441
 *      s t a r t _ s e r v e r
 
442
 *
 
443
 **************************************
 
444
 *
 
445
 * Functional description
 
446
 *      start the superserver using guardian process
 
447
 *
 
448
 **************************************/
 
449
        TEXT msg[MSG_LEN];
 
450
 
 
451
/* If we are currently attached and host has not been changed,
 
452
   server on this host is up and running.
 
453
*/
 
454
        if (data->attached && !(data->reattach & REA_HOST)) {
 
455
                SRVRMGR_msg_get(MSG_SRVUP, msg);
 
456
                fprintf(OUTFILE, "%s\n", msg);
 
457
                return true;
 
458
        }
 
459
 
 
460
        if (data->attached) {
 
461
                detach_service(data);
 
462
                data->reattach |= (REA_HOST | REA_USER | REA_PASSWORD);
 
463
        }
 
464
 
 
465
        fb_assert(data->reattach);
 
466
 
 
467
/* Let's see if server is already running, try to attach to it
 
468
*/
 
469
        if (server_is_up(data) == true) {
 
470
                SRVRMGR_msg_get(MSG_SRVUP, msg);
 
471
                fprintf(OUTFILE, "%s\n", msg);
 
472
                return true;
 
473
        }
 
474
 
 
475
/* We failed to attach to service, thus server might not be running
 
476
   You know what? We'll try to start it.
 
477
*/
 
478
        TEXT path[MAXPATHLEN];
 
479
        gds__prefix(path, SERVER_GUARDIAN);
 
480
        
 
481
        // CVC: Newer compilers won't accept assigning literal strings to non-const
 
482
        // char pointers, so this code prevents changing argv's type to const TEXT* argv[4]
 
483
        // that may not be accepted by execv().
 
484
        static char option_o[] = "-o";
 
485
        static char option_s[] = "-s";
 
486
        static char option_f[] = "-f";
 
487
        static char option_p[] = "-p";
 
488
 
 
489
        TEXT *argv[5];
 
490
        argv[0] = path;
 
491
        if (data->suboperation == SOP_START_ONCE)
 
492
                argv[1] = option_o;
 
493
        else if (data->suboperation == SOP_START_SIGNORE)
 
494
                argv[1] = option_s;
 
495
        else
 
496
                argv[1] = option_f;
 
497
        argv[2] = NULL;
 
498
        argv[3] = NULL;
 
499
        if (data->pidfile[0]) {
 
500
                argv[2] = option_p;
 
501
                argv[3] = data->pidfile;
 
502
        }
 
503
        argv[4] = NULL;
 
504
 
 
505
#ifdef DEBUG
 
506
        printf("Argument list:\n\"%s\"\n\"%s\"\n", argv[0], argv[1]);
 
507
#endif
 
508
 
 
509
        pid_t pid;
 
510
#if (defined SOLARIS_MT)
 
511
/* Accoding Sun's documentation vfork()  is not MT-safe
 
512
   while linking with libthreads, fork1 - fork one thread
 
513
*/
 
514
        if (!(pid = fork1())) {
 
515
                if (execv(path, argv) == -1) {
 
516
                        printf("Could not create child process %s with args %s \n",
 
517
                                   path, argv[1]);
 
518
                }
 
519
                _exit(FINI_ERROR);
 
520
        }
 
521
 
 
522
#else
 
523
 
 
524
        if (!(pid = vfork())) {
 
525
                execv(path, argv);
 
526
                _exit(FINI_ERROR);
 
527
        }
 
528
#endif
 
529
 
 
530
/* Wait a little bit to let the server start
 
531
*/
 
532
        sleep(ATTACH_PAUSE);
 
533
        for (int retry = ATTACH_RETRY; retry; retry--) {
 
534
                sleep(ATTACH_PAUSE);
 
535
 
 
536
                /* What we want to do here is to find out if the server has
 
537
                   started or not. We do it by trying to attach to the server
 
538
                   by calling isc_service_attach (in server_is_up()).
 
539
                   But in a local server startup (and this the way it works
 
540
                   currently) before calling isc_service_attach, we can check
 
541
                   if the child process (ibguard) exited or not. If it did,
 
542
                   then the server exited with startup error and there is no
 
543
                   need to try to attach to it.
 
544
                 */
 
545
                int exit_status; // unused after the call below.
 
546
                const pid_t ret_value = waitpid(pid, &exit_status, WNOHANG);
 
547
 
 
548
                /* waitpid() returns guardian process pid if the server has
 
549
                   exited (or killed by a signal), -1 if error happened,
 
550
                   0 if an exit status of a child process is unavailable (that
 
551
                   means in our case that the server is running).
 
552
                 */
 
553
#if (defined SOLARIS_MT)
 
554
                // Trying to understand why it died
 
555
                if ((ret_value == pid) && ( WIFEXITED(exit_status)
 
556
                                        || WCOREDUMP(exit_status)
 
557
                                        || WIFSIGNALED(exit_status)))
 
558
                {
 
559
                        printf("Guardian process %ld terminated with code %ld\n",
 
560
                                pid, WEXITSTATUS(exit_status)); 
 
561
                        break;
 
562
                }
 
563
 
 
564
#else            
 
565
 
 
566
 
 
567
                if (ret_value == pid) {
 
568
#ifdef DEBUG
 
569
                        printf("Guardian process %ld terminated\n", pid);
 
570
#endif
 
571
                        break;
 
572
                }
 
573
 
 
574
#endif /* SOLARIS_MT */
 
575
 
 
576
#ifdef DEBUG
 
577
                else if (ret_value == -1) {
 
578
                        printf("waitpid returned error, errno = %ld\n", errno);
 
579
                }
 
580
#endif
 
581
 
 
582
#ifdef DEBUG
 
583
                printf("Attach retries left: %d\n", retry);
 
584
#endif
 
585
                if (server_is_up(data) == true) {
 
586
                        SRVRMGR_msg_get(MSG_SRVUPOK, msg);
 
587
                        fprintf(OUTFILE, "%s\n", msg);
 
588
                        return true;
 
589
                }
 
590
        }
 
591
        SRVRMGR_msg_get(MSG_STARTERR, msg);
 
592
        fprintf(OUTFILE, "%s\n", msg);
 
593
        return false;
 
594
}
 
595
 
 
596
 
 
597
static bool server_is_up( ibmgr_data_t* data)
 
598
{
 
599
/**************************************
 
600
 *
 
601
 *      s e r v e r _ i s _ u p
 
602
 *
 
603
 **************************************
 
604
 *
 
605
 * Functional description
 
606
 *      checks if superserver is running
 
607
 *      trying to attach to "anonymous" service.
 
608
 *
 
609
 **************************************/
 
610
        ISC_STATUS_ARRAY status;
 
611
        TEXT svc_name[128];
 
612
        isc_svc_handle svc_handle = 0;
 
613
 
 
614
/* Obviously we should not be already attached to service
 
615
*/
 
616
        fb_assert(!data->attached);
 
617
 
 
618
        bool up = true;
 
619
 
 
620
/* To find out if we the server is already running we
 
621
   will try to attach to it. We are going to use "anonymous"
 
622
   service in order not to get an error like wrong user/password
 
623
*/
 
624
        strcpy(svc_name, data->host);
 
625
        strcat(svc_name, ":anonymous");
 
626
        isc_service_attach(status, 0, svc_name, &svc_handle, 0, "");
 
627
 
 
628
        if (status[0] == 1 && status[1] > 0) {
 
629
#ifdef DEBUG
 
630
                fprintf(OUTFILE, "server_is_up ERROR: %lu\n", status[1]);
 
631
#endif
 
632
                fb_assert(status[1] != isc_svcnotdef);
 
633
 
 
634
                /* Server can be running but attach could fail for
 
635
                   other reasons. For example, attach could return
 
636
                   not enough memory error. Let's take care of it.
 
637
                 */
 
638
                if (status[1] == isc_virmemexh)
 
639
                        up = true;
 
640
                else
 
641
                        up = false;
 
642
        }
 
643
        isc_service_detach(status, &svc_handle);
 
644
        return up;
 
645
}
 
646
 
 
647
 
 
648
static bool print_pool( ibmgr_data_t* data)
 
649
{
 
650
/**************************************
 
651
 *
 
652
 *      p r i n t _ p o o l
 
653
 *
 
654
 **************************************
 
655
 *
 
656
 * Functional description
 
657
 *      Make the server print memory pools
 
658
 *
 
659
 **************************************/
 
660
 
 
661
/* We should be attached to ask for any service
 
662
*/
 
663
        fb_assert(data->attached);
 
664
 
 
665
        char sendbuf[512];
 
666
        char* sptr = sendbuf;
 
667
        const USHORT path_length = strlen(data->print_file);
 
668
        *sptr = isc_info_svc_dump_pool_info;
 
669
        ++sptr;
 
670
        add_word(reinterpret_cast<UCHAR*&>(sptr), path_length);
 
671
        strcpy(sptr, data->print_file);
 
672
        sptr += path_length;
 
673
 
 
674
        ISC_STATUS_ARRAY status;
 
675
        char respbuf[2];
 
676
        isc_service_query(status, &data->attached, 0, 0, NULL,
 
677
                                          sptr - sendbuf, sendbuf, sizeof(respbuf), respbuf);
 
678
        if (status[0] == 1 && status[1] > 0) {
 
679
                isc_print_status(status);
 
680
                return false;
 
681
        }
 
682
        return true;
 
683
}
 
684