Loading adb/fdevent.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -147,24 +147,34 @@ fdevent* fdevent_create(int fd, fd_func func, void* arg) { return fde; } void fdevent_destroy(fdevent* fde) { unique_fd fdevent_release(fdevent* fde) { check_main_thread(); if (fde == nullptr) return; if (!fde) { return {}; } if (!(fde->state & FDE_CREATED)) { LOG(FATAL) << "destroying fde not created by fdevent_create(): " << dump_fde(fde); } unique_fd result = std::move(fde->fd); if (fde->state & FDE_ACTIVE) { g_poll_node_map.erase(fde->fd.get()); g_poll_node_map.erase(result.get()); if (fde->state & FDE_PENDING) { g_pending_list.remove(fde); } fde->fd.reset(); fde->state = 0; fde->events = 0; } delete fde; return result; } void fdevent_destroy(fdevent* fde) { // Release, and then let unique_fd's destructor cleanup. fdevent_release(fde); } static void fdevent_update(fdevent* fde, unsigned events) { Loading adb/fdevent.h +4 −3 Original line number Diff line number Diff line Loading @@ -50,11 +50,12 @@ struct fdevent { */ fdevent *fdevent_create(int fd, fd_func func, void *arg); /* Uninitialize and deallocate an fdevent object that was ** created by fdevent_create() */ // Deallocate an fdevent object that was created by fdevent_create. void fdevent_destroy(fdevent *fde); // fdevent_destroy, except releasing the file descriptor previously owned by the fdevent. unique_fd fdevent_release(fdevent* fde); /* Change which events should cause notifications */ void fdevent_set(fdevent *fde, unsigned events); Loading adb/test_device.py +4 −3 Original line number Diff line number Diff line Loading @@ -751,7 +751,7 @@ class FileOperationsTest(DeviceTest): shutil.rmtree(host_dir) def test_push_empty(self): """Push a directory containing an empty directory to the device.""" """Push an empty directory to the device.""" self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR]) self.device.shell(['mkdir', self.DEVICE_TEMP_DIR]) Loading @@ -767,9 +767,10 @@ class FileOperationsTest(DeviceTest): self.device.push(empty_dir_path, self.DEVICE_TEMP_DIR) test_empty_cmd = ['[', '-d', os.path.join(self.DEVICE_TEMP_DIR, 'empty')] remote_path = os.path.join(self.DEVICE_TEMP_DIR, "empty") test_empty_cmd = ["[", "-d", remote_path, "]"] rc, _, _ = self.device.shell_nocheck(test_empty_cmd) self.assertEqual(rc, 0) self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR]) finally: Loading Loading
adb/fdevent.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -147,24 +147,34 @@ fdevent* fdevent_create(int fd, fd_func func, void* arg) { return fde; } void fdevent_destroy(fdevent* fde) { unique_fd fdevent_release(fdevent* fde) { check_main_thread(); if (fde == nullptr) return; if (!fde) { return {}; } if (!(fde->state & FDE_CREATED)) { LOG(FATAL) << "destroying fde not created by fdevent_create(): " << dump_fde(fde); } unique_fd result = std::move(fde->fd); if (fde->state & FDE_ACTIVE) { g_poll_node_map.erase(fde->fd.get()); g_poll_node_map.erase(result.get()); if (fde->state & FDE_PENDING) { g_pending_list.remove(fde); } fde->fd.reset(); fde->state = 0; fde->events = 0; } delete fde; return result; } void fdevent_destroy(fdevent* fde) { // Release, and then let unique_fd's destructor cleanup. fdevent_release(fde); } static void fdevent_update(fdevent* fde, unsigned events) { Loading
adb/fdevent.h +4 −3 Original line number Diff line number Diff line Loading @@ -50,11 +50,12 @@ struct fdevent { */ fdevent *fdevent_create(int fd, fd_func func, void *arg); /* Uninitialize and deallocate an fdevent object that was ** created by fdevent_create() */ // Deallocate an fdevent object that was created by fdevent_create. void fdevent_destroy(fdevent *fde); // fdevent_destroy, except releasing the file descriptor previously owned by the fdevent. unique_fd fdevent_release(fdevent* fde); /* Change which events should cause notifications */ void fdevent_set(fdevent *fde, unsigned events); Loading
adb/test_device.py +4 −3 Original line number Diff line number Diff line Loading @@ -751,7 +751,7 @@ class FileOperationsTest(DeviceTest): shutil.rmtree(host_dir) def test_push_empty(self): """Push a directory containing an empty directory to the device.""" """Push an empty directory to the device.""" self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR]) self.device.shell(['mkdir', self.DEVICE_TEMP_DIR]) Loading @@ -767,9 +767,10 @@ class FileOperationsTest(DeviceTest): self.device.push(empty_dir_path, self.DEVICE_TEMP_DIR) test_empty_cmd = ['[', '-d', os.path.join(self.DEVICE_TEMP_DIR, 'empty')] remote_path = os.path.join(self.DEVICE_TEMP_DIR, "empty") test_empty_cmd = ["[", "-d", remote_path, "]"] rc, _, _ = self.device.shell_nocheck(test_empty_cmd) self.assertEqual(rc, 0) self.device.shell(['rm', '-rf', self.DEVICE_TEMP_DIR]) finally: Loading