#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
-#define SLQ_DEBUG(lvl, _slq, state) do { if (CHECK_DEBUGLVL(lvl)) { \
- const struct sl_query *__slq = _slq; \
- struct timeval_buf start_buf; \
- const char *start; \
- struct timeval_buf last_used_buf; \
- const char *last_used; \
- struct timeval_buf expire_buf; \
- const char *expire; \
- start = timeval_str_buf(&__slq->start_time, false, \
- true, &start_buf); \
- last_used = timeval_str_buf(&__slq->last_used, false, \
- true, &last_used_buf); \
- expire = timeval_str_buf(&__slq->expire_time, false, \
- true, &expire_buf); \
- DEBUG(lvl,("%s slq[0x%jx,0x%jx], start: %s, last_used: %s, " \
- "expires: %s, query: '%s'\n", state, \
- (uintmax_t)__slq->ctx1, (uintmax_t)__slq->ctx2, \
- start, last_used, expire, __slq->query_string)); \
-}} while(0)
-
struct slrpc_cmd {
const char *name;
bool (*function)(struct mds_ctx *mds_ctx,
* not as the user.
*/
if (!become_authenticated_pipe_user(slq->mds_ctx->pipe_session_info)) {
- DBG_ERR("can't become authenticated user: %d\n", slq->mds_ctx->uid);
+ DBG_ERR("can't become authenticated user: %d\n",
+ slq->mds_ctx->uid);
smb_panic("can't become authenticated user");
}
if (geteuid() != slq->mds_ctx->uid) {
- DEBUG(0, ("uid mismatch: %d/%d\n", geteuid(), slq->mds_ctx->uid));
+ DBG_ERR("uid mismatch: %d/%d\n", geteuid(), slq->mds_ctx->uid);
smb_panic("uid mismatch");
}
* set of IDs. Note that we're faking CNIDs by using
* filesystem inode numbers here
*/
- ok = bsearch(&ino64, slq->cnids, slq->cnids_num,
- sizeof(uint64_t), cnid_comp_fn);
+ ok = bsearch(&ino64,
+ slq->cnids,
+ slq->cnids_num,
+ sizeof(uint64_t),
+ cnid_comp_fn);
if (!ok) {
goto done;
}
* we return as part of the result set of a query
*/
result = dalloc_add_copy(slq->query_results->cnids->ca_cnids,
- &ino64, uint64_t);
+ &ino64,
+ uint64_t);
if (result != 0) {
- DEBUG(1, ("dalloc error\n"));
+ DBG_ERR("dalloc error\n");
slq->state = SLQ_STATE_ERROR;
return;
}
- ok = add_filemeta(slq->reqinfo, slq->query_results->fm_array,
- path, &sb);
+ ok = add_filemeta(slq->reqinfo,
+ slq->query_results->fm_array,
+ path,
+ &sb);
if (!ok) {
- DEBUG(1, ("add_filemeta error\n"));
+ DBG_ERR("add_filemeta error\n");
slq->state = SLQ_STATE_ERROR;
return;
}
goto error;
}
-
reqinfo = dalloc_value_for_key(query, "DALLOC_CTX", 0,
"DALLOC_CTX", 1, "kMDAttributeArray");
if (reqinfo == NULL) {
/**
* Init callbacks at startup
+ *
+ * This gets typically called in the main parent smbd which means we can't
+ * initialize our global state here.
**/
bool mds_init(struct messaging_context *msg_ctx)
{
return true;
}
+/**
+ * Tear down connections and free all resources
+ **/
+static int mds_ctx_destructor_cb(struct mds_ctx *mds_ctx)
+{
+ /*
+ * We need to free query_list before ino_path_map
+ */
+ while (mds_ctx->query_list != NULL) {
+ /*
+ * slq destructor removes element from list.
+ * Don't use TALLOC_FREE()!
+ */
+ talloc_free(mds_ctx->query_list);
+ }
+ TALLOC_FREE(mds_ctx->ino_path_map);
+
+ if (mds_ctx->tracker_con != NULL) {
+ g_object_unref(mds_ctx->tracker_con);
+ }
+ if (mds_ctx->gcancellable != NULL) {
+ g_cancellable_cancel(mds_ctx->gcancellable);
+ g_object_unref(mds_ctx->gcancellable);
+ }
+
+ ZERO_STRUCTP(mds_ctx);
+
+ return 0;
+}
+
/**
* Initialise a context per RPC bind
*
return NULL;
}
-/**
- * Tear down connections and free all resources
- **/
-int mds_ctx_destructor_cb(struct mds_ctx *mds_ctx)
-{
- /*
- * We need to free query_list before ino_path_map
- */
- while (mds_ctx->query_list != NULL) {
- /*
- * slq destructor removes element from list.
- * Don't use TALLOC_FREE()!
- */
- talloc_free(mds_ctx->query_list);
- }
- TALLOC_FREE(mds_ctx->ino_path_map);
-
- if (mds_ctx->tracker_con != NULL) {
- g_object_unref(mds_ctx->tracker_con);
- }
- if (mds_ctx->gcancellable != NULL) {
- g_cancellable_cancel(mds_ctx->gcancellable);
- g_object_unref(mds_ctx->gcancellable);
- }
-
- ZERO_STRUCTP(mds_ctx);
-
- return 0;
-}
-
/**
* Dispatch a Spotlight RPC command
**/