Exemplo n.º 1
0
static ptree_walk_res_t
write_pending(const void *node, int level, void *arg, void *pwra)
{
	id_pde_map_t *ipm = (id_pde_map_t *)node;
	pds_session_t *pdss = arg;
	int buflen;
	char errdesc[256];
	char *buf;

	if (!pdss->pdss_write)
		goto freeing;
	buflen = pasprintf(&buf, "%s%s200-%s is pending, key %s "
	    "latest value \"%s\" (%s)\n", pdss->pdss_report_cmdtag ?
	    pdss->pdss_report_cmdtag : "", pdss->pdss_report_cmdtag ?
	    " " : "", ipm->ipm_id, ipm->ipm_key, ipm->ipm_val,
	    pdict_reason_str(ipm->ipm_reason));
	if (buf) {
#ifndef _MSC_EXTENSIONS
#ifdef DEBUG_PROTOCOL
		if (debug_protocol)
			write(1, buf, buflen);
#endif
#endif
		if (!pdss->pdss_write(pdss->pdss_wfd, buf, buflen +
		    pdss->pdss_client_cr_null, errdesc, sizeof (errdesc))) {
#ifdef DEBUG_PROTOCOL
			pu_log(PUL_WARN, pdss->pdss_id,
			    "write error while reporting:");
			pu_log(PUL_WARN, pdss->pdss_id, errdesc);
#endif
		}
		free(buf); buf = NULL;
	} else {
		pu_log(PUL_WARN, pdss->pdss_id,
		    "some notifications dropped due to low-memory condition");
	}
freeing:
	free((void *)ipm->ipm_key); ipm->ipm_key = NULL;
	free((void *)ipm->ipm_val); ipm->ipm_val = NULL;
	free(ipm); ipm = NULL;

	return 1;
}
Exemplo n.º 2
0
static ptree_walk_res_t
write_pending(const void *node, int level, void *a, void *pwra)
{
	//void **arg = a;
	id_pde_map_t *ipm = (id_pde_map_t *)node;
	pds_session_t *pdss = (pds_session_t *)a;
	//ptree_node_t **pending = arg[1];
	int buflen;
	char errdesc[256];
	char *buf;
	void *ov;
	
	if (!pdss->pdss_write)
		goto freeing;
	buflen = pasprintf(&buf, "%s%s200-%s is pending, key %s "
					   "latest value \"%s\" (%s)\n", pdss->pdss_report_cmdtag ?
					   pdss->pdss_report_cmdtag : "", pdss->pdss_report_cmdtag ?
					   " " : "", ipm->ipm_id, ipm->ipm_key, ipm->ipm_val,
					   pdict_reason_str(ipm->ipm_reason));
	if (buf) {
		if (!pdss->pdss_write(pdss->pdss_wfd, buf, buflen +
							  pdss->pdss_client_cr_null, errdesc, sizeof (errdesc))) {
			//pu_log(PUL_WARN, pdss->pdss_id, "write error while reporting: %s",errdesc);
		}
		free(buf); buf = NULL;
	} else {
		pu_log(PUL_WARN, pdss->pdss_id, "some notifications dropped due to low-memory condition");
	}
freeing:
	ptree_inorder_walk_remove(&pdss->pdss_pending, &ov, pwra, ipmcmp);
	assert(node == ov);
	free((void *)ipm->ipm_key); //ipm->ipm_key = NULL;
	free((void *)ipm->ipm_val); //ipm->ipm_val = NULL;
	free(ov); ov = NULL;
	
	return 1;
}