#define POP3_PORT 110
#define POP3S_PORT 995
+enum pop_state {
+ POP_NEW,
+ POP_READY,
+};
+
typedef struct pop_data_t {
int refcnt;
- job_t *w;
+ enum pop_state state;
+
+ volatile job_t *w;
ACCOUNT act;
} pop_data_t;
static void pop_data_wipe(pop_data_t *pd)
{
if (pd->w)
- IGNORE(el_job_release(pd->w, EL_KILLED));
+ IGNORE(el_job_release((job_t *)pd->w, EL_KILLED));
}
static void pop_data_delete(pop_data_t **tp)
{
{
pop_data_t *pd = NULL;
+ el_lock();
for (int i = 0; i < conns.len; i++) {
if (mutt_account_match(act, &conns.arr[i]->act)) {
pd = pop_data_dup(conns.arr[i]);
pd = pop_data_new();
pd->act = *act;
}
+ if (!pd->w) {
+ pd->w = el_job_start(&pop_machine, pd);
+ }
+ while (pd->w && pd->state != POP_READY) {
+ el_wait(pd->w);
+ }
+ if (!pd->w)
+ pop_data_delete(&pd);
+ el_unlock();
return pd;
}
p_clear(&url, 1);
mutt_account_tourl(&act, &url);
- el_lock();
pd = pop_find_conn(&act);
- if (false) {
+ if (pd) {
ctx->data = pd;
url_ciss_tostring(&url, buf, sizeof (buf), 0);
m_strreplace(&ctx->path, buf);
- } else {
- pop_data_delete(&pd);
}
- el_unlock();
-
- return -1;
+ return 0;
}
mx_t const pop_mx_ng = {