static ssize_t _sock_cq_write(struct sock_cq *cq, fi_addr_t addr, const void *buf, size_t len) { ssize_t ret; fastlock_acquire(&cq->lock); if (rbfdavail(&cq->cq_rbfd) < len) { ret = -FI_ENOSPC; SOCK_LOG_ERROR("Not enough space in CQ\n"); goto out; } rbwrite(&cq->addr_rb, &addr, sizeof(addr)); rbcommit(&cq->addr_rb); rbfdwrite(&cq->cq_rbfd, buf, len); rbfdcommit(&cq->cq_rbfd); ret = len; if (cq->signal) sock_wait_signal(cq->waitset); out: fastlock_release(&cq->lock); return ret; }
static inline void sock_cq_copy_overflow_list(struct sock_cq *cq, size_t count) { ssize_t i; struct sock_cq_overflow_entry_t *overflow_entry; for (i = 0; i < count && !dlist_empty(&cq->overflow_list); i++) { overflow_entry = container_of(cq->overflow_list.next, struct sock_cq_overflow_entry_t, entry); rbwrite(&cq->addr_rb, &overflow_entry->addr, sizeof(fi_addr_t)); rbcommit(&cq->addr_rb); rbfdwrite(&cq->cq_rbfd, &overflow_entry->cq_entry[0], overflow_entry->len); rbfdcommit(&cq->cq_rbfd); dlist_remove(&overflow_entry->entry); free(overflow_entry); } }
static ssize_t _sock_cq_write(struct sock_cq *cq, fi_addr_t addr, const void *buf, size_t len) { ssize_t ret; struct sock_cq_overflow_entry_t *overflow_entry; fastlock_acquire(&cq->lock); if (rbfdavail(&cq->cq_rbfd) < len) { SOCK_LOG_ERROR("Not enough space in CQ\n"); overflow_entry = calloc(1, sizeof(*overflow_entry) + len); if (!overflow_entry) { ret = -FI_ENOSPC; goto out; } memcpy(&overflow_entry->cq_entry[0], buf, len); overflow_entry->len = len; overflow_entry->addr = addr; dlist_insert_tail(&overflow_entry->entry, &cq->overflow_list); ret = len; goto out; } rbwrite(&cq->addr_rb, &addr, sizeof(addr)); rbcommit(&cq->addr_rb); rbfdwrite(&cq->cq_rbfd, buf, len); if (cq->domain->progress_mode == FI_PROGRESS_MANUAL) rbcommit(&cq->cq_rbfd.rb); else rbfdcommit(&cq->cq_rbfd); ret = len; if (cq->signal) sock_wait_signal(cq->waitset); out: fastlock_release(&cq->lock); return ret; }
static ssize_t _sock_cq_write(struct sock_cq *cq, fi_addr_t addr, const void *buf, size_t len) { ssize_t ret; fastlock_acquire(&cq->lock); if(rbfdavail(&cq->cq_rbfd) < len) { ret = -FI_ENOSPC; goto out; } rbfdwrite(&cq->cq_rbfd, buf, len); rbfdcommit(&cq->cq_rbfd); ret = len; rbwrite(&cq->addr_rb, &addr, sizeof(fi_addr_t)); rbcommit(&cq->addr_rb); out: fastlock_release(&cq->lock); return ret; }