/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2019-08-24 15:20:41 UTC
  • Revision ID: teddy@recompile.se-20190824152041-8w32uk5na9hcs8gd
Server: Fully use new GLib.io_add_watch() call signature

* mandos: When calling GLib.io_add_watch(), always pass a channel as
          the first argument instead of a file descriptor.  This is
          supported by PyGObject 3.8 or later.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1150
1150
                kwargs=popen_args)
1151
1151
            self.checker.start()
1152
1152
            self.checker_callback_tag = GLib.io_add_watch(
1153
 
                pipe[0].fileno(), GLib.PRIORITY_DEFAULT, GLib.IO_IN,
 
1153
                GLib.IOChannel.unix_new(pipe[0].fileno()),
 
1154
                GLib.PRIORITY_DEFAULT, GLib.IO_IN,
1154
1155
                self.checker_callback, pipe[0], command)
1155
1156
        # Re-run this periodically if run by GLib.timeout_add
1156
1157
        return True
2680
2681
    def add_pipe(self, parent_pipe, proc):
2681
2682
        # Call "handle_ipc" for both data and EOF events
2682
2683
        GLib.io_add_watch(
2683
 
            parent_pipe.fileno(), GLib.PRIORITY_DEFAULT,
2684
 
            GLib.IO_IN | GLib.IO_HUP,
 
2684
            GLib.IOChannel.unix_new(parent_pipe.fileno()),
 
2685
            GLib.PRIORITY_DEFAULT, GLib.IO_IN | GLib.IO_HUP,
2685
2686
            functools.partial(self.handle_ipc,
2686
2687
                              parent_pipe=parent_pipe,
2687
2688
                              proc=proc))
2725
2726
                return False
2726
2727
 
2727
2728
            GLib.io_add_watch(
2728
 
                parent_pipe.fileno(), GLib.PRIORITY_DEFAULT,
2729
 
                GLib.IO_IN | GLib.IO_HUP,
 
2729
                GLib.IOChannel.unix_new(parent_pipe.fileno()),
 
2730
                GLib.PRIORITY_DEFAULT, GLib.IO_IN | GLib.IO_HUP,
2730
2731
                functools.partial(self.handle_ipc,
2731
2732
                                  parent_pipe=parent_pipe,
2732
2733
                                  proc=proc,
3602
3603
                sys.exit(1)
3603
3604
            # End of Avahi example code
3604
3605
 
3605
 
        GLib.io_add_watch(tcp_server.fileno(), GLib.PRIORITY_DEFAULT,
3606
 
                          GLib.IO_IN,
3607
 
                          lambda *args, **kwargs:
3608
 
                          (tcp_server.handle_request
3609
 
                           (*args[2:], **kwargs) or True))
 
3606
        GLib.io_add_watch(
 
3607
            GLib.IOChannel.unix_new(tcp_server.fileno()),
 
3608
            GLib.PRIORITY_DEFAULT, GLib.IO_IN,
 
3609
            lambda *args, **kwargs: (tcp_server.handle_request
 
3610
                                     (*args[2:], **kwargs) or True))
3610
3611
 
3611
3612
        logger.debug("Starting main loop")
3612
3613
        main_loop.run()