qmerge_get (struct qmerge **x, const iopause_fd *io, const struct taia *when)
{
    int r = 0;
    struct qmerge *qm = *x;

    if (qm->state == -1)
        return -1; /* previous error */
    if (qm->state == 0)
        return 0; /* no packet */
    if (qm->state == 2)
        return 1; /* already got packet */

    r = dns_transmit_get (&qm->dt, io, when);
    switch (r)
    {
    case -1: /* error */
    case  0: /* must wait for i/o */
        qm->state = r;
        return r;

    case 1: /* got packet */
        qm->state = 2;
        return r;
    }

    return -1; /* bug */
}
qmerge_get (struct qmerge **x, const iopause_fd *io, const struct taia *when)
{
    int r = 0;
    struct qmerge *qm = *x;

    if (qm->state == -1)
        return -1;  
    if (qm->state == 0)
        return 0;  
    if (qm->state == 2)
        return 1;  

    r = dns_transmit_get (&qm->dt, io, when);
    switch (r)
    {
    case -1:  
    case  0:  
        qm->state = r;
        return r;

    case 1:  
        qm->state = 2;
        return r;
    }

    return -1;  
}