/** * @brief * Recover a queue from the database * * @param[in] qname - Name of the queue to recover * * @return The recovered queue structure * @retval NULL - Failure * @retval !NULL - Success - address of recovered queue returned * */ pbs_queue * que_recov_db(char *qname) { pbs_queue *pq; pbs_db_que_info_t dbque; pbs_db_attr_info_t attr_info; pbs_db_obj_info_t obj; pbs_db_conn_t *conn = (pbs_db_conn_t *) svr_db_conn; obj.pbs_db_obj_type = PBS_DB_QUEUE; obj.pbs_db_un.pbs_db_que = &dbque; pq = que_alloc(qname); /* allocate & init queue structure space */ if (pq == (pbs_queue *)0) { log_err(-1, "que_recov", "que_alloc failed"); return ((pbs_queue *)0); } /* load server_qs */ strcpy(dbque.qu_name, qname); if (pbs_db_begin_trx(conn, 0, 0) !=0) goto db_err; /* read in job fixed sub-structure */ if (pbs_db_load_obj(conn, &obj) != 0) goto db_err; db_to_svr_que(pq, &dbque); attr_info.parent_id = pq->qu_qs.qu_name; attr_info.parent_obj_type = PARENT_TYPE_QUE_ALL; /* que attr */ /* read in que attributes */ if (recov_attr_db(conn, pq, &attr_info, que_attr_def, pq->qu_attr, (int)QA_ATR_LAST, 0) != 0) goto db_err; if (pbs_db_end_trx(conn, PBS_DB_COMMIT) != 0) goto db_err; /* all done recovering the queue */ return (pq); db_err: log_err(-1, "que_recov", "read of queuedb failed"); (void) pbs_db_end_trx(conn, PBS_DB_ROLLBACK); if (pq) que_free(pq); return 0; }
/** * @brief * Recover a queue from the database * * @param[in] qname - Name of the queue to recover * * @return The recovered queue structure * @retval NULL - Failure * @retval !NULL - Success - address of recovered queue returned * */ pbs_queue * que_recov_db(char *qname) { pbs_queue *pq; pbs_db_que_info_t dbque; pbs_db_obj_info_t obj; pbs_db_conn_t *conn = (pbs_db_conn_t *) svr_db_conn; obj.pbs_db_obj_type = PBS_DB_QUEUE; obj.pbs_db_un.pbs_db_que = &dbque; pq = que_alloc(qname); /* allocate & init queue structure space */ if (pq == NULL) { log_err(-1, "que_recov", "que_alloc failed"); return NULL; } /* load server_qs */ dbque.qu_name[sizeof(dbque.qu_name) - 1] = '\0'; strncpy(dbque.qu_name, qname, sizeof(dbque.qu_name)); /* read in job fixed sub-structure */ if (pbs_db_load_obj(conn, &obj) != 0) goto db_err; if (db_to_svr_que(pq, &dbque) != 0) goto db_err; pbs_db_reset_obj(&obj); /* all done recovering the queue */ return (pq); db_err: log_err(-1, "que_recov", "read of queuedb failed"); if (pq) que_free(pq); return 0; }