DEBUG(5,("set_file_oplock: granted oplock on file %s, %s/%lu, "
"tv_sec = %x, tv_usec = %x\n",
- fsp->fsp_name, file_id_string_tos(&fsp->file_id),
+ fsp_str_dbg(fsp), file_id_string_tos(&fsp->file_id),
fsp->fh->gen_id, (int)fsp->open_time.tv_sec,
(int)fsp->open_time.tv_usec ));
NULL);
if (lck == NULL) {
DEBUG(0,("remove_oplock: failed to lock share entry for "
- "file %s\n", fsp->fsp_name ));
+ "file %s\n", fsp_str_dbg(fsp)));
return False;
}
ret = remove_share_oplock(lck, fsp);
if (!ret) {
DEBUG(0,("remove_oplock: failed to remove share oplock for "
"file %s fnum %d, %s\n",
- fsp->fsp_name, fsp->fnum, file_id_string_tos(&fsp->file_id)));
+ fsp_str_dbg(fsp), fsp->fnum,
+ file_id_string_tos(&fsp->file_id)));
}
release_file_oplock(fsp);
TALLOC_FREE(lck);
NULL);
if (lck == NULL) {
DEBUG(0,("downgrade_oplock: failed to lock share entry for "
- "file %s\n", fsp->fsp_name ));
+ "file %s\n", fsp_str_dbg(fsp)));
return False;
}
ret = downgrade_share_oplock(lck, fsp);
if (!ret) {
DEBUG(0,("downgrade_oplock: failed to downgrade share oplock "
"for file %s fnum %d, file_id %s\n",
- fsp->fsp_name, fsp->fnum, file_id_string_tos(&fsp->file_id)));
+ fsp_str_dbg(fsp), fsp->fnum,
+ file_id_string_tos(&fsp->file_id)));
}
downgrade_file_oplock(fsp);
Set up an oplock break message.
****************************************************************************/
-static char *new_break_smb_message(TALLOC_CTX *mem_ctx,
+static char *new_break_message_smb1(TALLOC_CTX *mem_ctx,
files_struct *fsp, uint8 cmd)
{
char *result = TALLOC_ARRAY(mem_ctx, char, smb_size + 8*2 + 0);
if(fsp->oplock_type == NO_OPLOCK) {
if( DEBUGLVL( 3 ) ) {
- dbgtext( "initial_break_processing: file %s ", fsp->fsp_name );
+ dbgtext( "initial_break_processing: file %s ",
+ fsp_str_dbg(fsp));
dbgtext( "(file_id = %s gen_id = %lu) has no oplock.\n",
file_id_string_tos(&id), fsp->fh->gen_id );
dbgtext( "Allowing break to succeed regardless.\n" );
/* Remove the timed event handler. */
TALLOC_FREE(fsp->oplock_timeout);
- DEBUG(0, ("Oplock break failed for file %s -- replying anyway\n", fsp->fsp_name));
+ DEBUG(0, ("Oplock break failed for file %s -- replying anyway\n",
+ fsp_str_dbg(fsp)));
global_client_failed_oplock_break = True;
remove_oplock(fsp);
reply_to_oplock_break_requests(fsp);
}
}
+static void send_break_message_smb1(files_struct *fsp, uint8_t level)
+{
+ char *break_msg = new_break_message_smb1(talloc_tos(),
+ fsp,
+ level);
+ if (break_msg == NULL) {
+ exit_server("Could not talloc break_msg\n");
+ }
+
+ show_msg(break_msg);
+ if (!srv_send_smb(smbd_server_fd(),
+ break_msg, false, 0,
+ IS_CONN_ENCRYPTED(fsp->conn),
+ NULL)) {
+ exit_server_cleanly("send_break_message_smb1: "
+ "srv_send_smb failed.");
+ }
+
+ TALLOC_FREE(break_msg);
+}
+
void break_level2_to_none_async(files_struct *fsp)
{
- char *break_msg;
+ struct smbd_server_connection *sconn = smbd_server_conn;
if (fsp->oplock_type == NO_OPLOCK) {
/* We already got a "break to none" message and we've handled
DEBUG(10,("process_oplock_async_level2_break_message: sending break "
"to none message for fid %d, file %s\n", fsp->fnum,
- fsp->fsp_name));
+ fsp_str_dbg(fsp)));
/* Now send a break to none message to our client. */
- break_msg = new_break_smb_message(NULL, fsp, OPLOCKLEVEL_NONE);
- if (break_msg == NULL) {
- exit_server("Could not talloc break_msg\n");
- }
-
- show_msg(break_msg);
- if (!srv_send_smb(smbd_server_fd(),
- break_msg, false, 0,
- IS_CONN_ENCRYPTED(fsp->conn),
- NULL)) {
- exit_server_cleanly("oplock_break: srv_send_smb failed.");
+ if (sconn->allow_smb2) {
+ send_break_message_smb2(fsp, OPLOCKLEVEL_NONE);
+ } else {
+ send_break_message_smb1(fsp, OPLOCKLEVEL_NONE);
}
- TALLOC_FREE(break_msg);
-
/* Async level2 request, don't send a reply, just remove the oplock. */
remove_oplock(fsp);
-
}
/*******************************************************************
message_to_share_mode_entry(&msg, (char *)data->data);
DEBUG(10, ("Got oplock async level 2 break message from pid %s: "
- "%s/%lu\n", procid_str(debug_ctx(), &src),
+ "%s/%lu\n", procid_str(talloc_tos(), &src),
file_id_string_tos(&msg.id), msg.share_file_id));
fsp = initial_break_processing(msg.id, msg.share_file_id);
struct server_id src,
DATA_BLOB *data)
{
+ struct smbd_server_connection *sconn = smbd_server_conn;
struct share_mode_entry msg;
files_struct *fsp;
- char *break_msg;
bool break_to_level2 = False;
if (data->data == NULL) {
message_to_share_mode_entry(&msg, (char *)data->data);
DEBUG(10, ("Got oplock break message from pid %s: %s/%lu\n",
- procid_str(debug_ctx(), &src), file_id_string_tos(&msg.id),
+ procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
msg.share_file_id));
fsp = initial_break_processing(msg.id, msg.share_file_id);
if (fsp == NULL) {
- /* a We hit race here. Break messages are sent, and before we
+ /* We hit a race here. Break messages are sent, and before we
* get to process this message, we have closed the file. Reply
* with 'ok, oplock broken' */
DEBUG(3, ("Did not find fsp\n"));
!EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
DEBUG(3, ("Already downgraded oplock on %s: %s\n",
file_id_string_tos(&fsp->file_id),
- fsp->fsp_name));
+ fsp_str_dbg(fsp)));
/* We just send the same message back. */
messaging_send_buf(msg_ctx, src, MSG_SMB_BREAK_RESPONSE,
(uint8 *)data->data,
break_to_level2 = True;
}
- break_msg = new_break_smb_message(NULL, fsp, break_to_level2 ?
- OPLOCKLEVEL_II : OPLOCKLEVEL_NONE);
- if (break_msg == NULL) {
- exit_server("Could not talloc break_msg\n");
- }
-
- /* Need to wait before sending a break message if we sent ourselves this message. */
+ /* Need to wait before sending a break
+ message if we sent ourselves this message. */
if (procid_is_me(&src)) {
wait_before_sending_break();
}
- show_msg(break_msg);
- if (!srv_send_smb(smbd_server_fd(),
- break_msg, false, 0,
- IS_CONN_ENCRYPTED(fsp->conn),
- NULL)) {
- exit_server_cleanly("oplock_break: srv_send_smb failed.");
+ if (sconn->allow_smb2) {
+ send_break_message_smb2(fsp, break_to_level2 ?
+ OPLOCKLEVEL_II : OPLOCKLEVEL_NONE);
+ } else {
+ send_break_message_smb1(fsp, break_to_level2 ?
+ OPLOCKLEVEL_II : OPLOCKLEVEL_NONE);
}
- TALLOC_FREE(break_msg);
-
fsp->sent_oplock_break = break_to_level2 ? LEVEL_II_BREAK_SENT:BREAK_TO_NONE_SENT;
msg.pid = src;
struct server_id src,
DATA_BLOB *data)
{
+ struct smbd_server_connection *sconn = smbd_server_conn;
struct file_id id;
unsigned long file_id;
files_struct *fsp;
- char *break_msg;
if (data->data == NULL) {
DEBUG(0, ("Got NULL buffer\n"));
file_id = (unsigned long)IVAL(data->data, 24);
DEBUG(10, ("Got kernel oplock break message from pid %s: %s/%u\n",
- procid_str(debug_ctx(), &src), file_id_string_tos(&id),
+ procid_str(talloc_tos(), &src), file_id_string_tos(&id),
(unsigned int)file_id));
fsp = initial_break_processing(id, file_id);
return;
}
- break_msg = new_break_smb_message(NULL, fsp, OPLOCKLEVEL_NONE);
- if (break_msg == NULL) {
- exit_server("Could not talloc break_msg\n");
- }
-
- show_msg(break_msg);
- if (!srv_send_smb(smbd_server_fd(),
- break_msg, false, 0,
- IS_CONN_ENCRYPTED(fsp->conn),
- NULL)) {
- exit_server_cleanly("oplock_break: srv_send_smb failed.");
+ if (sconn->allow_smb2) {
+ send_break_message_smb2(fsp, OPLOCKLEVEL_NONE);
+ } else {
+ send_break_message_smb1(fsp, OPLOCKLEVEL_NONE);
}
- TALLOC_FREE(break_msg);
-
fsp->sent_oplock_break = BREAK_TO_NONE_SENT;
add_oplock_timeout_handler(fsp);
message_to_share_mode_entry(&msg, (char *)data->data);
DEBUG(10, ("Got oplock break response from pid %s: %s/%lu mid %u\n",
- procid_str(debug_ctx(), &src), file_id_string_tos(&msg.id),
+ procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
msg.share_file_id, (unsigned int)msg.op_mid));
- /* Here's the hack from open.c, store the mid in the 'port' field */
- schedule_deferred_open_smb_message(msg.op_mid);
+ schedule_deferred_open_message_smb(msg.op_mid);
}
static void process_open_retry_message(struct messaging_context *msg_ctx,
message_to_share_mode_entry(&msg, (char *)data->data);
DEBUG(10, ("Got open retry msg from pid %s: %s mid %u\n",
- procid_str(debug_ctx(), &src), file_id_string_tos(&msg.id),
+ procid_str(talloc_tos(), &src), file_id_string_tos(&msg.id),
(unsigned int)msg.op_mid));
- schedule_deferred_open_smb_message(msg.op_mid);
+ schedule_deferred_open_message_smb(msg.op_mid);
}
/****************************************************************************
NULL);
if (lck == NULL) {
DEBUG(0,("release_level_2_oplocks_on_change: failed to lock "
- "share mode entry for file %s.\n", fsp->fsp_name ));
+ "share mode entry for file %s.\n", fsp_str_dbg(fsp)));
return;
}