1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-13 13:18:06 +03:00

Move initialize_async_io_handler() inside of smbd/aio.c.

Call from actual aio read or write. No reason to call this globally on startup.

Jeremy.
This commit is contained in:
Jeremy Allison 2010-04-01 16:47:59 -07:00
parent b6aabcd628
commit bf90969892
3 changed files with 42 additions and 38 deletions

View File

@ -6047,7 +6047,6 @@ struct regval_ctr *svcctl_fetch_regvalues( const char *name, NT_USER_TOKEN *toke
/* The following definitions come from smbd/aio.c */
void initialize_async_io_handler(void);
bool schedule_aio_read_and_X(connection_struct *conn,
struct smb_request *req,
files_struct *fsp, SMB_OFF_T startpos,

View File

@ -35,6 +35,42 @@
#endif
#endif
/****************************************************************************
Initialize the signal handler for aio read/write.
*****************************************************************************/
static void smbd_aio_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;
unsigned int mid = (unsigned int)info->si_value.sival_int;
smbd_aio_complete_mid(mid);
}
static void initialize_async_io_handler(void)
{
if (aio_signal_event) {
return;
}
aio_signal_event = tevent_add_signal(smbd_event_context(),
smbd_event_context(),
RT_SIGNAL_AIO, SA_SIGINFO,
smbd_aio_signal_handler,
NULL);
if (!aio_signal_event) {
exit_server("Failed to setup RT_SIGNAL_AIO handler");
}
/* tevent supports 100 signal with SA_SIGINFO */
aio_pending_size = 100;
}
/****************************************************************************
The buffer we keep around whilst an aio request is in process.
*****************************************************************************/
@ -154,6 +190,9 @@ bool schedule_aio_read_and_X(connection_struct *conn,
bufsize = smb_size + 12 * 2 + smb_maxcnt;
/* Ensure aio is initialized. */
initialize_async_io_handler();
if ((aio_ex = create_aio_extra(fsp, bufsize)) == NULL) {
DEBUG(10,("schedule_aio_read_and_X: malloc fail.\n"));
return False;
@ -247,6 +286,9 @@ bool schedule_aio_write_and_X(connection_struct *conn,
return False;
}
/* Ensure aio is initialized. */
initialize_async_io_handler();
bufsize = smb_size + 6*2;
if (!(aio_ex = create_aio_extra(fsp, bufsize))) {
@ -535,17 +577,6 @@ void smbd_aio_complete_mid(unsigned int mid)
TALLOC_FREE(aio_ex);
}
static void smbd_aio_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;
unsigned int mid = (unsigned int)info->si_value.sival_int;
smbd_aio_complete_mid(mid);
}
/****************************************************************************
We're doing write behind and the client closed the file. Wait up to 30
seconds (my arbitrary choice) for the aio to complete. Return 0 if all writes
@ -675,30 +706,7 @@ void cancel_aio_by_fsp(files_struct *fsp)
}
}
/****************************************************************************
Initialize the signal handler for aio read/write.
*****************************************************************************/
void initialize_async_io_handler(void)
{
aio_signal_event = tevent_add_signal(smbd_event_context(),
smbd_event_context(),
RT_SIGNAL_AIO, SA_SIGINFO,
smbd_aio_signal_handler,
NULL);
if (!aio_signal_event) {
exit_server("Failed to setup RT_SIGNAL_AIO handler");
}
/* tevent supports 100 signal with SA_SIGINFO */
aio_pending_size = 100;
}
#else
void initialize_async_io_handler(void)
{
}
bool schedule_aio_read_and_X(connection_struct *conn,
struct smb_request *req,
files_struct *fsp, SMB_OFF_T startpos,

View File

@ -2852,9 +2852,6 @@ void smbd_process(void)
if (!init_oplocks(smbd_messaging_context()))
exit_server("Failed to init oplocks");
/* Setup aio signal handler. */
initialize_async_io_handler();
/* register our message handlers */
messaging_register(smbd_messaging_context(), NULL,
MSG_SMB_FORCE_TDIS, msg_force_tdis);