Exemple #1
0
int internal_opque_add(opque_t *que, op_generic_t *gop, int dolock)
{
    int err = 0;
    callback_t *cb;
    que_data_t *q = &(que->qd);

    //** Create the callback **
    type_malloc(cb, callback_t, 1);
    callback_set(cb, _opque_cb, (void *)gop); //** Set the global callback for the list

    if (dolock != 0) lock_opque(q);

    log_printf(15, "opque_add: qid=%d gid=%d\n", que->op.base.id, gop_get_id(gop));

    //** Add the list CB to the the op
//  lock_gop(gop)
    gop->base.parent_q = que;
    callback_append(&(gop->base.cb), cb);
//  unlock_gop(gop)

    //**Add the op to the q
    q->nsubmitted++;
    q->nleft++;
    if (q->opque->op.base.started_execution == 0) {
        move_to_bottom(q->list);
        insert_below(q->list, (void *)cb);
    }

    if (dolock != 0) unlock_opque(q);

    if (q->opque->op.base.started_execution == 1) {
        if (gop->type == Q_TYPE_OPERATION) {
            log_printf(15, "gid=%d started_execution=%d\n", gop_get_id(gop), gop->base.started_execution);
            gop->base.started_execution = 1;
            gop->base.pc->fn->submit(gop->base.pc->arg, gop);
        } else {  //** It's a queue
            opque_start_execution(gop->q->opque);
        }
    }

    return(err);
}
Exemple #2
0
{
    char *errmsg;
    int rc,want_buf=0;

    Py_BEGIN_ALLOW_THREADS
    rc=libssh2_session_last_error(self->session, &errmsg, NULL, want_buf);
    Py_END_ALLOW_THREADS

    return Py_BuildValue("(i,s)", rc, errmsg);
}
/* }}} */

/* {{{ PYLIBSSH2_Session_callback_set
 */
static char PYLIBSSH2_Session_callback_set_doc[] = "\n\
callback_set(cbtype, callback)\n\
\n\
Set (or reset) a callback function\n\
\n\
@param cbtype\n\
@param callback\n\
@return\n\
@rtype ";

/*
void
x11_callback(LIBSSH2_SESSION *session, LIBSSH2_CHANNEL *channel, 
             const char *shost, int sport, void **abstract)
*/

static PyObject *py_callback_func = NULL;