Copyright (C) Andrew Tridgell 1992-1998
Copyright (C) Jeremy Allison 1998 - 2001
Copyright (C) Volker Lendecke 2005
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "messages.h"
+#include "../librpc/gen_ndr/open_files.h"
/****************************************************************************
Get the number of current exclusive oplocks.
}
fsp->oplock_timeout =
- event_add_timed(server_event_context(), fsp,
- timeval_current_ofs(OPLOCK_BREAK_TIMEOUT, 0),
- oplock_timeout_handler, fsp);
+ tevent_add_timer(fsp->conn->sconn->ev_ctx, fsp,
+ timeval_current_ofs(OPLOCK_BREAK_TIMEOUT, 0),
+ oplock_timeout_handler, fsp);
if (fsp->oplock_timeout == NULL) {
DEBUG(0, ("Could not add oplock timeout handler\n"));
the client for LEVEL2.
*******************************************************************/
-void process_oplock_async_level2_break_message(struct messaging_context *msg_ctx,
+static void process_oplock_async_level2_break_message(struct messaging_context *msg_ctx,
void *private_data,
uint32_t msg_type,
struct server_id src,
DATA_BLOB *data)
{
- struct smbd_server_connection *sconn;
struct share_mode_entry msg;
files_struct *fsp;
+ struct smbd_server_connection *sconn =
+ talloc_get_type_abort(private_data,
+ struct smbd_server_connection);
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
return;
}
- sconn = msg_ctx_to_sconn(msg_ctx);
- if (sconn == NULL) {
- DEBUG(1, ("could not find sconn\n"));
- return;
- }
-
if (data->length != MSG_SMB_SHARE_MODE_ENTRY_SIZE) {
DEBUG(0, ("Got invalid msg len %d\n", (int)data->length));
return;
message_to_share_mode_entry(&msg, (char *)data->data);
DEBUG(10, ("Got oplock async level 2 break message from pid %s: "
- "%s/%lu\n", server_id_str(talloc_tos(), &src),
- file_id_string_tos(&msg.id), msg.share_file_id));
+ "%s/%llu\n", server_id_str(talloc_tos(), &src),
+ file_id_string_tos(&msg.id),
+ (unsigned long long)msg.share_file_id));
fsp = initial_break_processing(sconn, msg.id, msg.share_file_id);
struct server_id src,
DATA_BLOB *data)
{
- struct smbd_server_connection *sconn;
struct share_mode_entry msg;
files_struct *fsp;
bool break_to_level2 = False;
+ struct smbd_server_connection *sconn =
+ talloc_get_type_abort(private_data,
+ struct smbd_server_connection);
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
return;
}
- sconn = msg_ctx_to_sconn(msg_ctx);
- if (sconn == NULL) {
- DEBUG(1, ("could not find sconn\n"));
- return;
- }
-
if (data->length != MSG_SMB_SHARE_MODE_ENTRY_SIZE) {
DEBUG(0, ("Got invalid msg len %d\n", (int)data->length));
return;
/* De-linearize incoming message. */
message_to_share_mode_entry(&msg, (char *)data->data);
- DEBUG(10, ("Got oplock break message from pid %s: %s/%lu\n",
- server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
- msg.share_file_id));
+ DEBUG(10, ("Got oplock break message from pid %s: %s/%llu\n",
+ server_id_str(talloc_tos(), &src),
+ file_id_string_tos(&msg.id),
+ (unsigned long long)msg.share_file_id));
fsp = initial_break_processing(sconn, msg.id, msg.share_file_id);
struct server_id src,
DATA_BLOB *data)
{
- struct smbd_server_connection *sconn;
struct file_id id;
unsigned long file_id;
files_struct *fsp;
+ struct smbd_server_connection *sconn =
+ talloc_get_type_abort(private_data,
+ struct smbd_server_connection);
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
return;
}
- sconn = msg_ctx_to_sconn(msg_ctx);
- if (sconn == NULL) {
- DEBUG(1, ("could not find sconn\n"));
- return;
- }
-
/* Pull the data from the message. */
pull_file_id_24((char *)data->data, &id);
file_id = (unsigned long)IVAL(data->data, 24);
DATA_BLOB *data)
{
struct share_mode_entry msg;
+ struct smbd_server_connection *sconn =
+ talloc_get_type_abort(private_data,
+ struct smbd_server_connection);
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
/* De-linearize incoming message. */
message_to_share_mode_entry(&msg, (char *)data->data);
- DEBUG(10, ("Got oplock break response from pid %s: %s/%lu mid %llu\n",
- server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
- msg.share_file_id, (unsigned long long)msg.op_mid));
+ DEBUG(10, ("Got oplock break response from pid %s: %s/%llu mid %llu\n",
+ server_id_str(talloc_tos(), &src),
+ file_id_string_tos(&msg.id),
+ (unsigned long long)msg.share_file_id,
+ (unsigned long long)msg.op_mid));
- schedule_deferred_open_message_smb(msg.op_mid);
+ schedule_deferred_open_message_smb(sconn, msg.op_mid);
}
static void process_open_retry_message(struct messaging_context *msg_ctx,
DATA_BLOB *data)
{
struct share_mode_entry msg;
-
+ struct smbd_server_connection *sconn =
+ talloc_get_type_abort(private_data,
+ struct smbd_server_connection);
+
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
return;
server_id_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
(unsigned long long)msg.op_mid));
- schedule_deferred_open_message_smb(msg.op_mid);
+ schedule_deferred_open_message_smb(sconn, msg.op_mid);
}
/****************************************************************************
Setup oplocks for this process.
****************************************************************************/
-bool init_oplocks(struct messaging_context *msg_ctx)
+bool init_oplocks(struct smbd_server_connection *sconn)
{
DEBUG(3,("init_oplocks: initializing messages.\n"));
- messaging_register(msg_ctx, NULL, MSG_SMB_BREAK_REQUEST,
+ messaging_register(sconn->msg_ctx, sconn, MSG_SMB_BREAK_REQUEST,
process_oplock_break_message);
- messaging_register(msg_ctx, NULL, MSG_SMB_ASYNC_LEVEL2_BREAK,
+ messaging_register(sconn->msg_ctx, sconn, MSG_SMB_ASYNC_LEVEL2_BREAK,
process_oplock_async_level2_break_message);
- messaging_register(msg_ctx, NULL, MSG_SMB_BREAK_RESPONSE,
+ messaging_register(sconn->msg_ctx, sconn, MSG_SMB_BREAK_RESPONSE,
process_oplock_break_response);
- messaging_register(msg_ctx, NULL, MSG_SMB_KERNEL_BREAK,
+ messaging_register(sconn->msg_ctx, sconn, MSG_SMB_KERNEL_BREAK,
process_kernel_oplock_break);
- messaging_register(msg_ctx, NULL, MSG_SMB_OPEN_RETRY,
+ messaging_register(sconn->msg_ctx, sconn, MSG_SMB_OPEN_RETRY,
process_open_retry_message);
if (lp_kernel_oplocks()) {
#if HAVE_KERNEL_OPLOCKS_IRIX
- koplocks = irix_init_kernel_oplocks(NULL);
+ koplocks = irix_init_kernel_oplocks(sconn);
#elif HAVE_KERNEL_OPLOCKS_LINUX
- koplocks = linux_init_kernel_oplocks(NULL);
+ koplocks = linux_init_kernel_oplocks(sconn);
#elif HAVE_ONEFS
#error Isilon, please check if the NULL context is okay here. Thanks!
- koplocks = onefs_init_kernel_oplocks(NULL);
+ koplocks = onefs_init_kernel_oplocks(sconn);
#endif
}