int px4_close(int fd) { int ret; if (valid_fd(fd)) { VDev *dev = (VDev *)(filemap[fd]->vdev); PX4_DEBUG("px4_close fd = %d", fd); ret = dev->close(filemap[fd]); filemap[fd] = NULL; } else { ret = -EINVAL; } if (ret < 0) { px4_errno = -ret; ret = PX4_ERROR; } return ret; }
int px4_close(int fd) { int ret; VDev *dev = get_vdev(fd); if (dev) { pthread_mutex_lock(&filemutex); ret = dev->close(filemap[fd]); filemap[fd] = nullptr; pthread_mutex_unlock(&filemutex); PX4_DEBUG("px4_close fd = %d", fd); } else { ret = -EINVAL; } if (ret < 0) { px4_errno = -ret; ret = PX4_ERROR; } return ret; }