static void close_and_report(config *cfg) { handle_close(cfg->in); handle_close(cfg->out); if (cfg->verbose) { report(cfg); } free(cfg->in); free(cfg->out); }
int fd_collection::add_cq_channel_fd(int cq_ch_fd, ring* p_ring) { fdcoll_logfunc("cq_ch_fd=%d", cq_ch_fd); if (!is_valid_fd(cq_ch_fd)) return -1; lock(); epfd_info* p_fd_info = get_epfd(cq_ch_fd); BULLSEYE_EXCLUDE_BLOCK_START if (p_fd_info) { fdcoll_logwarn("[fd=%d] Deleting old duplicate sockinfo object (%p)", cq_ch_fd, p_fd_info); unlock(); handle_close(cq_ch_fd, true); lock(); } BULLSEYE_EXCLUDE_BLOCK_END // Sanity check to remove any old objects using the same fd!! socket_fd_api* p_cq_ch_fd_api_obj = get_sockfd(cq_ch_fd); BULLSEYE_EXCLUDE_BLOCK_START if (p_cq_ch_fd_api_obj) { fdcoll_logwarn("[fd=%d] Deleting old duplicate object (%p)", cq_ch_fd, p_cq_ch_fd_api_obj); unlock(); handle_close(cq_ch_fd, true); lock(); } BULLSEYE_EXCLUDE_BLOCK_END // Check if cq_channel_info was already created cq_channel_info* p_cq_ch_info = get_cq_channel_fd(cq_ch_fd); BULLSEYE_EXCLUDE_BLOCK_START if (p_cq_ch_info) { fdcoll_logwarn("cq channel fd already exists in fd_collection"); m_p_cq_channel_map[cq_ch_fd] = NULL; delete p_cq_ch_info; p_cq_ch_info = NULL; } BULLSEYE_EXCLUDE_BLOCK_END unlock(); p_cq_ch_info = new cq_channel_info(p_ring); lock(); BULLSEYE_EXCLUDE_BLOCK_START if (p_cq_ch_info == NULL) { fdcoll_logpanic("[fd=%d] Failed creating new cq_channel_info (%m)", cq_ch_fd); } BULLSEYE_EXCLUDE_BLOCK_END m_p_cq_channel_map[cq_ch_fd] = p_cq_ch_info; unlock(); return 0; }
int fd_collection::addpipe(int fdrd, int fdwr) { fdcoll_logfunc("fdrd=%d, fdwr=%d", fdrd, fdwr); if (!is_valid_fd(fdrd) || !is_valid_fd(fdwr)) return -1; lock(); // Sanity check to remove any old objects using the same fd!! socket_fd_api* p_fdrd_api_obj = get_sockfd(fdrd); BULLSEYE_EXCLUDE_BLOCK_START if (p_fdrd_api_obj) { fdcoll_logwarn("[fd=%d] Deleting old duplicate object (%p)", fdrd, p_fdrd_api_obj); unlock(); handle_close(fdrd, true); lock(); } BULLSEYE_EXCLUDE_BLOCK_END socket_fd_api* p_fdwr_api_obj = get_sockfd(fdwr); BULLSEYE_EXCLUDE_BLOCK_START if (p_fdwr_api_obj) { fdcoll_logwarn("[fd=%d] Deleting old duplicate object (%p)", fdwr, p_fdwr_api_obj); unlock(); handle_close(fdwr, true); lock(); } BULLSEYE_EXCLUDE_BLOCK_END unlock(); p_fdrd_api_obj = new pipeinfo(fdrd); p_fdwr_api_obj = new pipeinfo(fdwr); lock(); BULLSEYE_EXCLUDE_BLOCK_START if (p_fdrd_api_obj == NULL) { fdcoll_logpanic("[fd=%d] Failed creating new pipeinfo (%m)", fdrd); } if (p_fdwr_api_obj == NULL) { fdcoll_logpanic("[fd=%d] Failed creating new pipeinfo (%m)", fdwr); } BULLSEYE_EXCLUDE_BLOCK_END m_p_sockfd_map[fdrd] = p_fdrd_api_obj; m_p_sockfd_map[fdwr] = p_fdwr_api_obj; unlock(); return 0; }
static void do_axis_proc(Widget w, XtPointer client_data, XtPointer call_data) { Widget wlabel; int x, y; set_wait_cursor(); if (axis_frame == NULL) { char *label1[2]; label1[0] = "Accept"; label1[1] = "Close"; XmGetPos(app_shell, 0, &x, &y); axis_frame = XmCreateDialogShell(app_shell, "Axis props", NULL, 0); handle_close(axis_frame); XtVaSetValues(axis_frame, XmNx, x, XmNy, y, NULL); axis_panel = XmCreateRowColumn(axis_frame, "axis_rc", NULL, 0); wlabel = XtVaCreateManagedWidget("Axis offset (viewport coordinates):", xmLabelWidgetClass, axis_panel, NULL); offx = CreateTextItem2(axis_panel, 10, "Left or bottom:"); offy = CreateTextItem2(axis_panel, 10, "Right or top:"); XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, axis_panel, NULL); CreateCommandButtons(axis_panel, 2, but1, label1); XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) accept_axis_proc, (XtPointer) 0); XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) axis_frame); XtManageChild(axis_panel); } XtRaise(axis_frame); update_axis_items(cg); unset_wait_cursor(); }
/* `fclose()' wrapper. */ int zfile_fclose(FILE *stream) { zfile_t *ptr; if (!zinit_done) { errno = EBADF; return -1; } /* Search for the matching file in the list. */ for (ptr = zfile_list; ptr != NULL; ptr = ptr->next) { if (ptr->stream == stream) { /* Close temporary file. */ if (fclose(stream) == -1) { return -1; } if (handle_close(ptr) < 0) { errno = EBADF; return -1; } return 0; } } return fclose(stream); }
static void dispatch(struct pfiled *pfiled, struct io *io) { if (cmdline_verbose) { fprintf(stderr, "io: 0x%p, req: 0x%p, op %u\n", (void *)io, (void *)io->req, io->req->op); } switch (io->req->op) { case X_READ: case X_WRITE: handle_read_write(pfiled, io); break; case X_INFO: handle_info(pfiled, io); break; case X_COPY: handle_copy(pfiled, io); break; case X_DELETE: handle_delete(pfiled, io); break; case X_OPEN: handle_open(pfiled, io); break; case X_CLOSE: handle_close(pfiled, io); break; // case X_SNAPSHOT: case X_SYNC: default: handle_unknown(pfiled, io); } }
int fd_collection::addepfd(int epfd, int size) { fdcoll_logfunc("epfd=%d", epfd); if (!is_valid_fd(epfd)) return -1; lock(); // Sanity check to remove any old sockinfo object using the same fd!! epfd_info* p_fd_info = get_epfd(epfd); if (p_fd_info) { fdcoll_logwarn("[fd=%d] Deleting old duplicate sockinfo object (%p)", epfd, p_fd_info); unlock(); handle_close(epfd, true); lock(); } unlock(); p_fd_info = new epfd_info(epfd, size); lock(); BULLSEYE_EXCLUDE_BLOCK_START if (p_fd_info == NULL) { fdcoll_logpanic("[fd=%d] Failed creating new sockinfo (%m)", epfd); } BULLSEYE_EXCLUDE_BLOCK_END m_p_epfd_map[epfd] = p_fd_info; m_epfd_lst.push_back(p_fd_info); unlock(); return 0; }
int GDCT_Service_Acceptor::stop_listen() { handle_close(); if(g_gdct_request != NULL) delete g_gdct_request; return 0; }
void ShortConnection::close() { //删除监听事件 REACTOR_INSTANCE()->delete_handler(this); //通知连接断开 CORE_DEBUG("short conn close, conn = " << this); handle_close(get_handle(), MASK_TIMEOUT); }
/* * Create the draw Frame and the draw Panel */ void create_draw_frame(Widget w, XtPointer client_data, XtPointer call_data) { int x, y; Widget buts[2]; Widget wlabel; set_wait_cursor(); if (draw_frame == NULL) { char *label1[2]; label1[0] = "Accept"; label1[1] = "Close"; XmGetPos(app_shell, 0, &x, &y); draw_frame = XmCreateDialogShell(app_shell, "Draw options", NULL, 0); handle_close(draw_frame); XtVaSetValues(draw_frame, XmNx, x, XmNy, y, NULL); draw_panel = XmCreateRowColumn(draw_frame, "draw_rc", NULL, 0); wlabel = XtVaCreateManagedWidget("Scroll %:", xmLabelWidgetClass, draw_panel, NULL); scrollper_item = XtVaCreateManagedWidget("scroll", xmScaleWidgetClass, draw_panel, XmNwidth, 200, XmNminimum, 0, XmNmaximum, 200, XmNvalue, 0, XmNshowValue, True, XmNprocessingDirection, XmMAX_ON_RIGHT, XmNorientation, XmHORIZONTAL, NULL); linkscroll_item = XtVaCreateManagedWidget("Linked scrolling", xmToggleButtonWidgetClass, draw_panel, NULL); autoredraw_type_item = XtVaCreateManagedWidget("Auto redraw", xmToggleButtonWidgetClass, draw_panel, NULL); autorefresh_type_item = XtVaCreateManagedWidget("Auto refresh", xmToggleButtonWidgetClass, draw_panel, NULL); cursor_type_item = XtVaCreateManagedWidget("Crosshair cursor", xmToggleButtonWidgetClass, draw_panel, NULL); XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, draw_panel, NULL); CreateCommandButtons(draw_panel, 2, buts, label1); XtAddCallback(buts[0], XmNactivateCallback, (XtCallbackProc) define_draw_proc, (XtPointer) 0); XtAddCallback(buts[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) draw_frame); XtManageChild(draw_panel); } XtRaise(draw_frame); update_draw(); unset_wait_cursor(); }
bool sockinfo::try_un_offloading() // un-offload the socket if possible { if (! this->isPassthrough()) { setPassthrough(); handle_close(m_fd, false, true); // will leave it for passthrough } return true; }
static int ev_handler(struct mg_connection *conn, enum mg_event ev) { switch (ev) { case MG_AUTH: return MG_TRUE; case MG_REQUEST: return handle_request(conn); case MG_RECV: return handle_recv(conn); case MG_CLOSE: return handle_close(conn); default: return MG_FALSE; } }
int handle_free(struct ludis_handle *h) { if (handle_close(h) != LUDIS_OK) return LUDIS_ERR; free(h); return LUDIS_OK; }
void CConnection::close() { //删除监听事件 REACTOR_INSTANCE()->delete_handler(this); //关闭SOCKET //sock_stream_.close(); //通知连接断开 CORE_DEBUG("connection close, conn = " << this); handle_close(get_handle(), MASK_TIMEOUT); }
QString ComplexShapeHandler::handle_path(QXmlStreamReader* reader) { QString returnString; pathWidth = 0; pathHeight = 0; QXmlStreamAttributes attrs = reader->attributes(); QString width = attrs.value("w").toString(); QString height = attrs.value("h").toString(); if (!width.isEmpty()) { pathWidth = width.toInt(); } if (!height.isEmpty()) { pathHeight = height.toInt(); } while (!reader->atEnd()) { reader->readNext(); if (reader->isEndElement() && reader->name() == "path") { if (attrs.value("stroke") == "false" || attrs.value("stroke") == "0" ) { returnString += "S "; } if (attrs.value("fill") == "none") { returnString += "F "; } break; } else if (reader->isStartElement() && reader->name() == "moveTo") { returnString += handle_moveTo(reader); } else if (reader->isStartElement() && reader->name() == "close") { returnString += handle_close(reader); } else if (reader->isStartElement() && reader->name() == "lnTo") { returnString += handle_lnTo(reader); } else if (reader->isStartElement() && reader->name() == "cubicBezTo") { returnString += handle_cubicBezTo(reader); } else if (reader->isStartElement() && reader->name() == "quadBezTo") { returnString += handle_quadBezTo(reader); } else if (reader->isStartElement() && reader->name() == "arcTo") { returnString += handle_arcTo(reader); } else if (reader->isStartElement()) { qDebug() << "UNHANDLED path sub element" << reader->name().toString(); } } return returnString; }
void on_message(connection_ptr connection,websocketpp::message::data_ptr msg) { typename std::set<connection_ptr>::iterator it; wscmd::cmd command = wscmd::parse(msg->get_payload()); if (command.command == "close") { handle_close(connection,command); } else { command_error(connection,"Invalid Command"); } }
static void process_close(u_int32_t id) { int handle, ret, status = SSH2_FX_FAILURE; handle = get_handle(); debug3("request %u: close handle %u", id, handle); handle_log_close(handle, NULL); ret = handle_close(handle); status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; send_status(id, status); }
void close_front_window( void) { WindowPtr wp; if((wp= FrontWindow()) != NULL) { handle_close(wp); } return; }
static void process_close(void) { u_int32_t id; int handle, ret, status = SSH2_FX_FAILURE; id = get_int(); handle = get_handle(); TRACE("close id %u handle %d", id, handle); ret = handle_close(handle); status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; send_status(id, status); }
void create_editp_frame(Widget w, XtPointer client_data, XtPointer call_data) { int x, y; static Widget top; Widget dialog; set_wait_cursor(); if (top == NULL) { Widget but1[3]; char *label1[3]; label1[0] = "Edit"; label1[1] = "Formula"; label1[2] = "Close"; XmGetPos(app_shell, 0, &x, &y); top = XmCreateDialogShell(app_shell, "Edit/Create set", NULL, 0); handle_close(top); XtVaSetValues(top, XmNx, x, XmNy, y, NULL); dialog = XmCreateRowColumn(top, "dialog_rc", NULL, 0); editp_set_item = CreateSetSelector(dialog, "Edit set:", SET_SELECT_NEXT, FILTER_SELECT_NONE, GRAPH_SELECT_CURRENT, SELECTION_TYPE_SINGLE); XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL); #ifdef HAVE_LIBXBAE ext_editor_item = XtVaCreateManagedWidget("Use external editor", xmToggleButtonWidgetClass, dialog, NULL); XmToggleButtonSetState( ext_editor_item, False, False ); XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, dialog, NULL); #endif CreateCommandButtons(dialog, 3, but1, label1); XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) edit_set_proc, NULL); XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) create_leval_frame, NULL); XtAddCallback(but1[2], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) top); XtAddCallback(editp_set_item.list, XmNsingleSelectionCallback, (XtCallbackProc) setsel_cred_cb, (XtPointer)but1[1] ); XtManageChild(dialog); } XtRaise(top); unset_wait_cursor(); }
static int _worker_dispatch_cb (evHandle *handle){ comoWorker *worker = handle->data; duk_context *ctx = worker->Mainctx; mtx_lock(&worker->mtx); QUEUE *q; while ( !QUEUE_EMPTY(&worker->queueOut) ){ q = QUEUE_HEAD(&(worker)->queueOut); QUEUE_REMOVE(q); comoQueue *queue = QUEUE_DATA(q, comoQueue, queue); if (worker->destroy != 0){ goto FREE; } duk_push_heapptr(ctx, worker->self); if (duk_get_type(ctx, -1) != DUK_TYPE_OBJECT){ dump_stack(ctx, "DUK"); assert(0); } como_push_worker_value(ctx, queue); duk_call(ctx, 1); duk_pop(ctx); FREE : /* free except in case of pointers */ if (queue->data != NULL && queue->type != DUK_TYPE_POINTER){ free(queue->data); } free(queue); } mtx_unlock(&worker->mtx); if (worker->destroy == 2){ duk_push_global_stash(ctx); duk_get_prop_string(ctx, -1, "comoWorkersCallBack"); duk_push_number(ctx, (double) handle->id); duk_del_prop(ctx, -2); handle_close(handle); free(worker); } return 0; }
static void process_close(u_int32_t id) { int r, handle, ret, status = SSH2_FX_FAILURE; if ((r = get_handle(iqueue, &handle)) != 0) fatal("%s: buffer error: %s", __func__, ssh_err(r)); debug3("request %u: close handle %u", id, handle); handle_log_close(handle, NULL); ret = handle_close(handle); status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; send_status(id, status); }
void handle_quit( void) { WindowPtr wp; NMBoolean cancelled= false; while((wp= FrontWindow())!= NULL) { cancelled= handle_close(wp); if(cancelled) break; } if(!cancelled) quitting= true; }
int shm_ctl_block_push (struct shm_queue *q, int fd, int type) { shm_block_t mb; mb.id = fds.cn[fd].id; mb.length = sizeof(shm_block_t); mb.type = type; mb.fd = fd; if (type == FIN_BLOCK) handle_close(fd, 1); return shmq_push(q, &mb, NULL); }
void SFTP::process_close(void) { u_int32_t id; int handle, ret, status = SSH2_FX_FAILURE; id = get_int(); handle = get_handle(); debug3("request %u: close handle %u", id, handle); handle_log_close(handle, NULL); ret = handle_close(handle); status = (!ret) ? errno_to_portable(::GetLastError ()) : SSH2_FX_OK; send_status(id, status); }
void TcpConnection::handle_read(const boost::system::error_code &ec, std::size_t bytes_transfered) { if (!ec) { if(read_callback_) { read_callback_(shared_from_this(), bytes_transfered); } socket_.async_read_some(boost::asio::buffer(readbuf_), std::bind( &TcpConnection::handle_read, this, std::placeholders::_1, std::placeholders::_2)); } else { if (ec.value() == boost::asio::error::eof) {// EOF handle_close(); } else { LOG_DEBUG<<ec.message(); } } }
static void process_close(u_int32_t id) { int handle, ret, status = SSH2_FX_FAILURE; handle = get_handle(); debug3("request %u: close handle %u", id, handle); handle_log_close(handle, NULL); ret = handle_close(handle); status = (ret == -1) ? errno_to_portable(errno) : SSH2_FX_OK; send_status(id, status); #ifdef NERSC_MOD s_audit("sftp_process_close_3", "count=%i int=%d int=%d int=%d", get_client_session_id(), (int)getppid(), id, handle); #endif }
int handle_vFile (char *own_buf, int packet_len, int *new_packet_len) { if (strncmp (own_buf, "vFile:open:", 11) == 0) handle_open (own_buf); else if (strncmp (own_buf, "vFile:pread:", 11) == 0) handle_pread (own_buf, new_packet_len); else if (strncmp (own_buf, "vFile:pwrite:", 12) == 0) handle_pwrite (own_buf, packet_len); else if (strncmp (own_buf, "vFile:close:", 12) == 0) handle_close (own_buf); else if (strncmp (own_buf, "vFile:unlink:", 13) == 0) handle_unlink (own_buf); else return 0; return 1; }
void Socket::on_error(const boost::system::error_code& error) { std::cout << "Socket Error : oops, connection lost :(" << std::endl; std::cout << "Socket Error : " << error.message() << std::endl; shutdown(); switch (error.value()) { case boost::asio::error::bad_descriptor: case boost::asio::error::eof: case boost::asio::error::operation_aborted: case boost::asio::error::connection_reset: { handle_close(); break; } } }
static void do_axisbar_proc(Widget w, XtPointer client_data, XtPointer call_data) { int x, y; set_wait_cursor(); if (axisbar_frame == NULL) { char *label1[2]; label1[0] = "Accept"; label1[1] = "Close"; XmGetPos(app_shell, 0, &x, &y); axisbar_frame = XmCreateDialogShell(app_shell, "Axis bar", NULL, 0); handle_close(axisbar_frame); XtVaSetValues(axisbar_frame, XmNx, x, XmNy, y, NULL); axisbar_panel = XmCreateRowColumn(axisbar_frame, "axisbar_rc", NULL, 0); barcolor = CreateColorChoice(axisbar_panel, "Color:", 0); barlinew = CreatePanelChoice(axisbar_panel, "Line width:", 10, "1", "2", "3", "4", "5", "6", "7", "8", "9", 0, 0); barlines = (Widget *) CreatePanelChoice(axisbar_panel, "Line style:", 6, "Solid line", "Dotted line", "Dashed line", "Long Dashed", "Dot-dashed", NULL, NULL); XtVaCreateManagedWidget("sep", xmSeparatorWidgetClass, axisbar_panel, NULL); CreateCommandButtons(axisbar_panel, 2, but1, label1); XtAddCallback(but1[0], XmNactivateCallback, (XtCallbackProc) accept_axisbar_proc, (XtPointer) 0); XtAddCallback(but1[1], XmNactivateCallback, (XtCallbackProc) destroy_dialog, (XtPointer) axisbar_frame); XtManageChild(axisbar_panel); } XtRaise(axisbar_frame); update_axisbar_items(cg); unset_wait_cursor(); }