int DbChannel::send_request(Dbt *request, u_int32_t nrequest, Dbt *response, db_timeout_t timeout, u_int32_t flags) { DB_CHANNEL *dbchannel = unwrap(this); DB_ENV *dbenv = unwrap(dbenv_); DBT *dbtlist; int i, ret; ret = __os_malloc(dbenv->env, sizeof(DBT) * nrequest, &dbtlist); if (ret != 0) { DB_ERROR(dbenv_, "DbChannel::send_request", ret, ON_ERROR_UNKNOWN); return (ret); } for (i = 0; i < (int)nrequest; i++) memcpy(&dbtlist[i], request[i].get_DBT(), sizeof(DBT)); if ((ret = dbchannel->send_request(dbchannel, dbtlist, nrequest, response->get_DBT(), timeout, flags)) != 0) DB_ERROR(dbenv_, "DbChannel::send_request", ret, ON_ERROR_UNKNOWN); __os_free(dbenv->env, dbtlist); return (ret); }
static int add_home(char *home) { home_entry *hp, *homep; int ret; if ((ret = __os_malloc(NULL, sizeof(home_entry), &hp)) != 0) return (ret); if ((ret = __os_malloc(NULL, strlen(home)+1, &hp->home)) != 0) return (ret); memcpy(hp->home, home, strlen(home)+1); hp->dir = home; hp->passwd = NULL; /* * This loop is to remove any trailing path separators, * to assure hp->name points to the last component. */ hp->name = __db_rpath(home); *(hp->name) = '\0'; hp->name++; while (*(hp->name) == '\0') { hp->name = __db_rpath(home); *(hp->name) = '\0'; hp->name++; } /* * Now we have successfully added it. Make sure there are no * identical names. */ for (homep = LIST_FIRST(&__dbsrv_home); homep != NULL; homep = LIST_NEXT(homep, entries)) if (strcmp(homep->name, hp->name) == 0) { printf("Already added home name %s, at directory %s\n", hp->name, homep->dir); return (-1); } LIST_INSERT_HEAD(&__dbsrv_home, hp, entries); if (__dbsrv_verbose) printf("Added home %s in dir %s\n", hp->name, hp->dir); return (0); }
int DbChannel::send_msg(Dbt *msg, u_int32_t nmsg, u_int32_t flags) { DB_CHANNEL *dbchannel = unwrap(this); DB_ENV *dbenv = unwrap(dbenv_); DBT *dbtlist; int i, ret; ret = __os_malloc(dbenv->env, sizeof(DBT) * nmsg, &dbtlist); if (ret != 0) { DB_ERROR(dbenv_, "DbChannel::send_msg", ret, ON_ERROR_UNKNOWN); return (ret); } for (i = 0; i < (int)nmsg; i++) memcpy(&dbtlist[i], msg[i].get_DBT(), sizeof(DBT)); if ((ret = dbchannel->send_msg(dbchannel, dbtlist, nmsg, flags)) != 0) DB_ERROR(dbenv_, "DbChannel::send_msg", ret, ON_ERROR_UNKNOWN); __os_free(dbenv->env, dbtlist); return (ret); }
extern "C" ct_entry * new_ct_ent(int *errp) { time_t t; ct_entry *ctp, *octp; int ret; if ((ret = __os_malloc(NULL, sizeof(ct_entry), &ctp)) != 0) { *errp = ret; return (NULL); } memset(ctp, 0, sizeof(ct_entry)); /* * Get the time as ID. We may service more than one request per * second however. If we are, then increment id value until we * find an unused one. We insert entries in LRU fashion at the * head of the list. So, if the first entry doesn't match, then * we know for certain that we can use our entry. */ if ((t = time(NULL)) == -1) { *errp = __os_get_errno(); __os_free(NULL, ctp); return (NULL); } octp = LIST_FIRST(&__dbsrv_head); if (octp != NULL && octp->ct_id >= t) t = octp->ct_id + 1; ctp->ct_id = t; ctp->ct_idle = __dbsrv_idleto; ctp->ct_activep = &ctp->ct_active; ctp->ct_origp = NULL; ctp->ct_refcount = 1; LIST_INSERT_HEAD(&__dbsrv_head, ctp, entries); return (ctp); }