static void linux_oplock_signal_handler(struct tevent_context *ev_ctx, struct tevent_signal *se, int signum, int count, void *_info, void *private_data) { siginfo_t *info = (siginfo_t *)_info; int fd = info->si_fd; files_struct *fsp; fsp = file_find_fd(smbd_server_conn, fd); if (fsp == NULL) { DEBUG(0,("linux_oplock_signal_handler: failed to find fsp for file fd=%d (file was closed ?)\n", fd )); return; } break_kernel_oplock(fsp->conn->sconn->msg_ctx, fsp); }
static BOOL linux_oplock_receive_message(fd_set *fds, char *buffer, int buffer_len) { int fd; struct files_struct *fsp; BlockSignals(True, RT_SIGNAL_LEASE); fd = fd_pending_array[0]; fsp = file_find_fd(fd); fd_pending_array[0] = (SIG_ATOMIC_T)-1; if (signals_received > 1) memmove((void *)&fd_pending_array[0], (void *)&fd_pending_array[1], sizeof(SIG_ATOMIC_T)*(signals_received-1)); signals_received--; /* now we can receive more signals */ BlockSignals(False, RT_SIGNAL_LEASE); if (fsp == NULL) { DEBUG(0,("Invalid file descriptor %d in kernel oplock break!\n", (int)fd)); return False; } DEBUG(3,("linux_oplock_receive_message: kernel oplock break request received for \ dev = %x, inode = %.0f fd = %d, fileid = %lu \n", (unsigned int)fsp->dev, (double)fsp->inode, fd, fsp->file_id)); /* * Create a kernel oplock break message. */ /* Setup the message header */ SIVAL(buffer,OPBRK_CMD_LEN_OFFSET,KERNEL_OPLOCK_BREAK_MSG_LEN); SSVAL(buffer,OPBRK_CMD_PORT_OFFSET,0); buffer += OPBRK_CMD_HEADER_LEN; SSVAL(buffer,OPBRK_MESSAGE_CMD_OFFSET,KERNEL_OPLOCK_BREAK_CMD); memcpy(buffer + KERNEL_OPLOCK_BREAK_DEV_OFFSET, (char *)&fsp->dev, sizeof(fsp->dev)); memcpy(buffer + KERNEL_OPLOCK_BREAK_INODE_OFFSET, (char *)&fsp->inode, sizeof(fsp->inode)); memcpy(buffer + KERNEL_OPLOCK_BREAK_FILEID_OFFSET, (char *)&fsp->file_id, sizeof(fsp->file_id)); return True; }