Example #1
0
static bool echo_write(conn_t *conn, struct buf *buf)
{
	if (!conn_write(conn, buf->bytes, buf->used)) {
		free(buf);
		return false;
	}

	conn_next(conn, echo_close, NULL);
	next_close(conn, buf);
	return true;
}
Example #2
0
pid_t fork(void)
{
  pid_t pid;

  pid = next_fork();

  if (pid == 0) {
    /* No need to lock in the child process. */
    if (comm_sd >= 0) {
      next_close(comm_sd);
      comm_sd = -1;
    }
  }

  return pid;
}
Example #3
0
/* Return an error when trying to close the comm_sd file descriptor
   (pretend that it's closed). */
int close(int fd)
{
  int retval, reterr;

  lock_comm_sd();

  if (comm_sd >= 0 && comm_sd == fd) {
    retval = -1;
    reterr = EBADF;
  } else {
    retval = next_close(fd);
    reterr = errno;
  }

  unlock_comm_sd();

  errno = reterr;
  return retval;
}
Example #4
0
int dup2(int oldfd, int newfd)
{
  int retval, reterr;

  lock_comm_sd();

  if (comm_sd >= 0 && comm_sd == newfd) {
    /* If dup fails, comm_sd gets set to -1, which is fine. */
    comm_sd = dup(newfd);
    next_close(newfd);
  }

  retval = next_dup2(oldfd, newfd);
  reterr = errno;

  unlock_comm_sd();

  errno = reterr;
  return retval;
}
Example #5
0
/*
  called when a open completes
*/
static void open_completed(struct smbcli_request *req)
{
	struct benchopen_state *state = (struct benchopen_state *)req->async.private_data;
	TALLOC_CTX *tmp_ctx = talloc_new(state->mem_ctx);
	NTSTATUS status;

	status = smb_raw_open_recv(req, tmp_ctx, &state->open_parms);

	talloc_free(tmp_ctx);

	state->req_open = NULL;

	if (NT_STATUS_EQUAL(status, NT_STATUS_END_OF_FILE) ||
	    NT_STATUS_EQUAL(status, NT_STATUS_LOCAL_DISCONNECT) ||
	    NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) {
		talloc_free(state->tree);
		talloc_free(state->cli);
		state->tree = NULL;
		state->cli = NULL;
		num_connected--;	
		DEBUG(0,("[%u] reopening connection to %s\n",
			 state->client_num, state->dest_host));
		talloc_free(state->te);
		state->te = event_add_timed(state->ev, state->mem_ctx, 
					    timeval_current_ofs(1,0), 
					    reopen_connection, state);
		return;
	}

	if (NT_STATUS_EQUAL(status, NT_STATUS_SHARING_VIOLATION)) {
		DEBUG(2,("[%d] retrying open %d\n",
			 state->client_num, state->pending_file_num));
		state->open_retries++;
		state->req_open = smb_raw_open_send(state->tree, &state->open_parms);
		state->req_open->async.fn = open_completed;
		state->req_open->async.private_data = state;
		return;
	}

	if (!NT_STATUS_IS_OK(status)) {
		open_failed++;
		DEBUG(0,("[%u] open failed %d - %s\n",
			 state->client_num, state->pending_file_num,
			 nt_errstr(status)));
		return;
	}

	state->close_file_num = state->open_file_num;
	state->close_fnum = state->open_fnum;
	state->open_file_num = state->pending_file_num;
	state->open_fnum = state->open_parms.ntcreatex.out.file.fnum;

	DEBUG(2,("[%d] open completed %d (fnum[%d])\n",
		 state->client_num, state->open_file_num, state->open_fnum));

	if (state->close_fnum != -1) {
		next_close(state);
	}

	next_open(state);
}