Add timestamp to create/close FD notifications
authorAntoine Busque <antoinebusque@gmail.com>
Thu, 9 Apr 2015 16:54:20 +0000 (12:54 -0400)
committerAntoine Busque <antoinebusque@gmail.com>
Thu, 9 Apr 2015 16:54:20 +0000 (12:54 -0400)
linuxautomaton/linuxautomaton/io.py
linuxautomaton/linuxautomaton/sched.py
linuxautomaton/linuxautomaton/statedump.py

index 3fa1e41607241c09b4afc841c475013e774a643f..09b29139e830d45fb727a32cad8e02de5e2a4c79 100644 (file)
@@ -192,7 +192,7 @@ class IoStateProvider(sp.StateProvider):
             oldfd = event['oldfd']
             newfd = event['newfd']
             if newfd in fds:
-                self._close_fd(parent_proc, newfd)
+                self._close_fd(parent_proc, newfd, event.timestamp)
         elif name == 'fcntl':
             # Only handle if cmd == F_DUPFD (0)
             if event['cmd'] != 0:
@@ -276,7 +276,7 @@ class IoStateProvider(sp.StateProvider):
                                          parent_proc=parent_proc)
 
         if isinstance(io_rq, sv.CloseIORequest) and ret == 0:
-            self._close_fd(proc, io_rq.fd)
+            self._close_fd(proc, io_rq.fd, io_rq.end_ts)
 
     def _create_fd(self, proc, io_rq):
         parent_proc = self._get_parent_proc(proc)
@@ -289,26 +289,30 @@ class IoStateProvider(sp.StateProvider):
 
             self._state.send_notification_cb('create_fd',
                                              fd=io_rq.fd,
-                                             parent_proc=parent_proc)
+                                             parent_proc=parent_proc,
+                                             timestamp=io_rq.end_ts)
         elif isinstance(io_rq, sv.ReadWriteIORequest):
             if io_rq.fd_in is not None and io_rq.fd_in not in parent_proc.fds:
                 parent_proc.fds[io_rq.fd_in] = sv.FD(io_rq.fd_in)
                 self._state.send_notification_cb('create_fd',
                                                  fd=io_rq.fd_in,
-                                                 parent_proc=parent_proc)
+                                                 parent_proc=parent_proc,
+                                                 timestamp=io_rq.end_ts)
 
             if io_rq.fd_out is not None and \
                io_rq.fd_out not in parent_proc.fds:
                 parent_proc.fds[io_rq.fd_out] = sv.FD(io_rq.fd_out)
                 self._state.send_notification_cb('create_fd',
                                                  fd=io_rq.fd_out,
-                                                 parent_proc=parent_proc)
+                                                 parent_proc=parent_proc,
+                                                 timestamp=io_rq.end_ts)
 
-    def _close_fd(self, proc, fd):
+    def _close_fd(self, proc, fd, timestamp):
         parent_proc = self._get_parent_proc(proc)
         self._state.send_notification_cb('close_fd',
                                          fd=fd,
-                                         parent_proc=parent_proc)
+                                         parent_proc=parent_proc,
+                                         timestamp=timestamp)
         del parent_proc.fds[fd]
 
     def _get_parent_proc(self, proc):
index 9a7fbeec73ff0731b29af26f932832f22f4ade27..28cf0b7467db5c632710d32a1698ded35a7e97bf 100644 (file)
@@ -141,7 +141,8 @@ class SchedStateProvider(sp.StateProvider):
             # the child_proc created by the fork
             self._state.send_notification_cb('create_fd',
                                              fd=fd,
-                                             parent_proc=child_proc)
+                                             parent_proc=child_proc,
+                                             timestamp=event.timestamp)
 
         self._state.tids[child_tid] = child_proc
 
@@ -166,5 +167,6 @@ class SchedStateProvider(sp.StateProvider):
         for fd in toremove:
             self._state.send_notification_cb('close_fd',
                                              fd=fd,
-                                             parent_proc=proc)
+                                             parent_proc=proc,
+                                             timestamp=event.timestamp)
             del proc.fds[fd]
index 0e6a371a2bedc68b98256a90dde750e299ad4ffe..28d331961f3986da9da4237fe5096f4ce9a53fd7 100644 (file)
@@ -90,12 +90,12 @@ class StatedumpStateProvider(sp.StateProvider):
             proc.fds[fd] = sv.FD(fd, filename, sv.FDType.unknown, cloexec)
             self._state.send_notification_cb('create_fd',
                                              fd=fd,
-                                             parent_proc=proc)
+                                             parent_proc=proc,
+                                             timestamp=event.timestamp)
         else:
             # just fix the filename
             proc.fds[fd].filename = filename
 
-    # FIXME: this is also used in IO Analysis, possibly move
     @staticmethod
     def _assign_fds_to_parent(proc, parent):
         if proc.fds:
This page took 0.025674 seconds and 5 git commands to generate.