~ubuntu-branches/debian/sid/rlinetd/sid

« back to all changes in this revision

Viewing changes to engine.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2007-03-21 23:21:31 UTC
  • mfrom: (2.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20070321232131-q05ux83vd5q6dosw
Tags: 0.6-3
* grammar.y: fix stack corruption error, that prevented rlinetd from
  stopping properly when RPC are enabled. The bug occurred in the
  rlp_cleanup() function, was introduced in the previous release and
  is caused by my misunderstanding of numlist_copy() function, which
  joins two lists together rather than making a simple copy.
  Simple NULL-ification of the destination list before the above function
  is called fixes the problem.
* grammar.y: fix similar bug, that happens when the rpc token is used
  in the "default" configuration section (however hardly likely anybody
  will ever configure rlinetd in that way).

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
struct rl_cleanup *rl_cleanups = NULL;
30
30
int hisock;
31
 
void (*parse)();
32
31
extern char *rl_parser;
33
32
struct pidtab *rl_pending;
34
33
struct rl_instance *inst_new();
42
41
struct fd_ops *rfd_ops = NULL, *wfd_ops = NULL;
43
42
int rfd_len = 0, wfd_len = 0;
44
43
 
 
44
/* runs the specified function from our parser library */
 
45
static void run_library_func(char* funcname) {
 
46
        int i;                          
 
47
        void *handle;
 
48
  void (*libfunc)();
 
49
        
 
50
  if((handle = dlopen(rl_parser, RTLD_NOW
 
51
#ifdef RTLD_GLOBAL
 
52
                                                                                        | RTLD_GLOBAL
 
53
#endif
 
54
                                                                                        ))) {
 
55
                if((libfunc = dlsym(handle, funcname))) {
 
56
                        int bound;
 
57
                                                
 
58
                        closelog();
 
59
                        i = 0;
 
60
                        if(rl_debug)
 
61
                                i = 3;
 
62
                        bound = FD_SETSIZE;
 
63
                        for(; i < bound; i++)
 
64
                                        close(i);
 
65
                        libfunc();
 
66
                } else {
 
67
                        rl_fatal(EX_SOFTWARE, "ABORT - failed to find function \"%s\" in parser module %s (%s)",
 
68
                                                 funcname, rl_parser, dlerror());
 
69
                }
 
70
        } else {
 
71
                                        rl_fatal(EX_SOFTWARE, "ABORT - failed to load parser module %s (%s)",
 
72
                                                                         rl_parser, dlerror());
 
73
        }
 
74
        dlclose(handle); 
 
75
}                               
 
76
 
45
77
void main_loop() {
46
78
        fd_set srfds, swfds;
47
 
        void *handle;
48
79
        
49
80
        for(;;) {
50
81
                int i, n;
53
84
                struct mallinfo m;
54
85
#endif          
55
86
 
 
87
                if (rls_term_recv) { /* received SIGTERM or SIGINT */
 
88
                        run_library_func("services_free");
 
89
                        return;
 
90
                }       
 
91
                                                
56
92
                if(rls_need_parse || rls_reaped) {
57
93
                        rls_block();
58
94
                        if(rls_need_parse) {
59
95
#ifdef HAVE_MALLINFO
60
96
                                m = mallinfo();
61
97
#endif
62
 
                                if((handle = dlopen(rl_parser, RTLD_NOW
63
 
#ifdef RTLD_GLOBAL
64
 
                                                                                                                | RTLD_GLOBAL
65
 
#endif
66
 
                                                                                                                ))) {
67
 
                                        if((parse = dlsym(handle, "parse"))) {
68
 
                                                int bound;
69
 
                                                
70
 
                                                closelog();
71
 
                                                i = 0;
72
 
                                                if(rl_debug)
73
 
                                                        i = 3;
74
 
                                                bound = FD_SETSIZE;
75
 
                                                for(; i < bound; i++)
76
 
                                                        close(i);
77
 
                                                parse();
78
 
                                        } else {
79
 
                                                rl_fatal(EX_SOFTWARE, "ABORT - failed to find parse function in parser module %s (%s)",
80
 
                                                                                 rl_parser, dlerror());
81
 
                                        }
82
 
                                } else {
83
 
                                        rl_fatal(EX_SOFTWARE, "ABORT - failed to load parser module %s (%s)",
84
 
                                                                         rl_parser, dlerror());
85
 
                                }
86
 
                                dlclose(handle); 
 
98
                                run_library_func("parse");
87
99
                                rls_need_parse = 0;
88
100
#ifdef HAVE_MALLINFO
89
101
                                m = mallinfo();