+static void send_break_message_smb1(files_struct *fsp, int 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(fsp->conn->sconn,
+ 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)
+{
+ struct smbd_server_connection *sconn = fsp->conn->sconn;
+
+ if (fsp->oplock_type == NO_OPLOCK) {
+ /* We already got a "break to none" message and we've handled
+ * it. just ignore. */
+ DEBUG(3, ("process_oplock_async_level2_break_message: already "
+ "broken to none, ignoring.\n"));
+ return;
+ }
+
+ if (fsp->oplock_type == FAKE_LEVEL_II_OPLOCK) {
+ /* Don't tell the client, just downgrade. */
+ DEBUG(3, ("process_oplock_async_level2_break_message: "
+ "downgrading fake level 2 oplock.\n"));
+ remove_oplock(fsp);
+ return;
+ }
+
+ /* Ensure we're really at level2 state. */
+ SMB_ASSERT(fsp->oplock_type == LEVEL_II_OPLOCK);
+
+ DEBUG(10,("process_oplock_async_level2_break_message: sending break "
+ "to none message for fid %d, file %s\n", fsp->fnum,
+ fsp_str_dbg(fsp)));
+
+ /* Now send a break to none message to our client. */
+ if (sconn->using_smb2) {
+ send_break_message_smb2(fsp, OPLOCKLEVEL_NONE);
+ } else {
+ send_break_message_smb1(fsp, OPLOCKLEVEL_NONE);
+ }
+
+ /* Async level2 request, don't send a reply, just remove the oplock. */
+ remove_oplock(fsp);
+}
+