int on_addr_resolved(struct rdma_cm_id *id) { struct ibv_qp_init_attr qp_attr; struct connection *conn; printf("address resolved.\n"); build_context(id->verbs); build_qp_attr(&qp_attr); TEST_NZ(rdma_create_qp(id, s_ctx->pd, &qp_attr)); id->context = conn = (struct connection *)malloc(sizeof(struct connection)); conn->id = id; conn->qp = id->qp; conn->num_completions = 0; register_memory(conn); post_receives(conn); TEST_NZ(rdma_resolve_route(id, TIMEOUT_IN_MS)); return 0; }
void build_connection(struct rdma_cm_id *id) { struct connection *conn; struct ibv_qp_init_attr qp_attr; //init semaphores sem_init(&read_ops, 0, 0); sem_init(&done_ops, 0, 0); sem_init(&write_ops, 0, 1); build_context(id->verbs); build_qp_attr(&qp_attr); TEST_NZ(rdma_create_qp(id, s_ctx->pd, &qp_attr)); id->context = conn = (struct connection *)malloc(sizeof(struct connection)); conn->id = id; conn->qp = id->qp; conn->send_state = SS_INIT; conn->recv_state = RS_INIT; conn->connected = 0; register_memory(conn); post_receives(conn); }
CalcCtx *calc_init(char music_name[]) { json_object *jb = json_object_from_file(music_name); if (jb == ERR_JSON_OBJ) { printf("could not find the Muisic Data File\n"); return NULL; } CalcCtx *pCtx = (CalcCtx*)malloc(sizeof(CalcCtx)); if (!pCtx) { printf("error malloc \n"); return NULL; } memset(pCtx, 0, sizeof(CalcCtx)); int ret = build_context(jb, pCtx); if (ret) { printf("could not find the Muisic Data File\n"); return NULL; } json_object_put(jb); return pCtx; }
JNIEXPORT void JNICALL Java_edu_cornell_vision_hadoop_HadoopPythonMRJob_00024Map_mapper_1map (JNIEnv * env, jobject thisObj, jlong impl, jobject key, jobject value, jobject context) { PyObject * mapper_context = NULL; PyObject * pykey = NULL; PyObject * pyvalue = NULL; PyObject * result = NULL; PyObject * faulthandler_enable_retval = NULL; //new PyObject * faulthandler_disable_retval = NULL; //new struct MapperImpl * ptr = (struct MapperImpl*)impl; HANDLE_PYTHON (mapper_context = build_context (env, context, ptr->dumps, ptr->faulthandler), "build map context") HANDLE_PYTHON(pykey = java_to_python (env, key, ptr->Text, ptr->Text_getBytes, ptr->Text_getLength, ptr->loads), "convert key to python"); HANDLE_PYTHON(pyvalue = java_to_python (env, value, ptr->Text, ptr->Text_getBytes, ptr->Text_getLength, ptr->loads), "convert value to python") #ifdef FAULTHANDLER HANDLE_PYTHON(faulthandler_enable_retval = PyObject_CallMethod(ptr->faulthandler, "enable", NULL), "enable faulthandler"); #endif HANDLE_PYTHON(result = PyObject_CallMethod (ptr->mapper, "map", "OOO", pykey, pyvalue, mapper_context), "mapper.map") #ifdef FAULTHANDLER HANDLE_PYTHON(faulthandler_disable_retval = PyObject_CallMethod(ptr->faulthandler, "disable", NULL), "disable faulthandler"); #endif failure: Py_XDECREF(faulthandler_enable_retval); Py_XDECREF(faulthandler_disable_retval); Py_XDECREF(mapper_context); Py_XDECREF(pyvalue); Py_XDECREF(pykey); Py_XDECREF(result); }
void build_connection(struct rdma_cm_id *id) { rdma_conn_t *conn; struct ibv_qp_init_attr qp_attr; build_context(id->verbs); build_qp_attr(&qp_attr); TEST_NZ(rdma_create_qp(id, s_ctx->pd, &qp_attr)); conn = malloc(sizeof(rdma_conn_t)); id->context = conn; rdma_conn = conn; conn->id = id; conn->qp = id->qp; conn->send_state = SS_INIT; conn->recv_state = RS_INIT; conn->connected = 0; register_memory(conn); post_receives(conn); }
void Connector::build_conn(struct rdma_cm_id* id_) { struct ibv_qp_init_attr qp_attr; build_context(id_->verbs); build_qp_attr(&qp_attr); TEST_NZ(rdma_create_qp(id_, s_ctx_->pd_, &qp_attr) ) }
int on_addr_resolved(struct rdma_cm_id *id) { printf("address resolved.\n"); build_context(id->verbs); build_connection(id); TEST_NZ(rdma_resolve_route(id, TIMEOUT_IN_MS)); return 0; }
static void gb_project_tree_builder_build_node (IdeTreeBuilder *builder, IdeTreeNode *node) { GbProjectTreeBuilder *self = (GbProjectTreeBuilder *)builder; GObject *item; g_return_if_fail (GB_IS_PROJECT_TREE_BUILDER (self)); item = ide_tree_node_get_item (node); if (IDE_IS_CONTEXT (item)) build_context (self, node); else if (GB_IS_PROJECT_FILE (item)) build_file (self, node); }
int on_addr_resolved(struct rdma_cm_id *id) { printf("address resolved.\n"); printf("build context and connection struct\n"); build_context(id->verbs); build_connection(id); post_receive_for_msg(id->context); struct connection * conn =(struct connection *)id->context; memset(conn->send_region,'1',send_buffer_size); //sprintf(conn->send_region, send_buffer_size, "%d",getpid()); TEST_NZ(rdma_resolve_route(id, TIMEOUT_IN_MS)); return 0; }
int on_connect_request(struct rdma_cm_id *id) { struct ibv_qp_init_attr qp_attr; struct rdma_conn_param cm_params; struct connection *conn; printf("received connection request.\n"); build_context(id->verbs); build_qp_attr(&qp_attr); TEST_NZ(rdma_create_qp(id, s_ctx->pd, &qp_attr)); id->context = conn = (struct connection *)malloc(sizeof(struct connection)); conn->qp = id->qp; register_memory(conn); post_receives(conn); memset(&cm_params, 0, sizeof(cm_params)); TEST_NZ(rdma_accept(id, &cm_params)); return 0; }
int main(int argc, char **argv) { int optidx= 0; char *user; char *password; char ***list, **p; size_t num_list, i, j, k; int failed = 0; setprogname (argv[0]); if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv, &optidx)) usage (1); if (help_flag) usage (0); if (version_flag) { print_version (NULL); return 0; } if (optidx != argc) usage (1); if (principals.num_strings == 0) errx(1, "no principals"); user = estrdup(principals.strings[0]); password = strchr(user, ':'); if (password == NULL) errx(1, "password missing from %s", user); *password++ = 0; if (slaves.num_strings == 0) errx(1, "no principals"); if (logfile_str) { printf("open logfile %s\n", logfile_str); logfile = fopen(logfile_str, "w+"); if (logfile == NULL) err(1, "failed to open: %s", logfile_str); } /* * */ list = permutate_all(&slaves, &num_list); /* * Set up connection to all clients */ printf("Connecting to slaves\n"); for (i = 0; i < slaves.num_strings; i++) connect_client(slaves.strings[i]); /* * Test acquire credentials */ printf("Test acquire credentials\n"); for (i = 0; i < slaves.num_strings; i++) { int32_t hCred, val; val = acquire_cred(clients[i], user, password, 1, &hCred); if (val != GSMERR_OK) { warnx("Failed to acquire_cred on host %s: %d", clients[i]->moniker, (int)val); failed = 1; } else toast_resource(clients[i], hCred); } if (failed) goto out; /* * First test if all slaves can build context to them-self. */ printf("Self context tests\n"); for (i = 0; i < num_clients; i++) { int32_t hCred, val, delegCred; int32_t clientC, serverC; struct client *c = clients[i]; if (c->target_name == NULL) continue; printf("%s connects to self using %s\n", c->moniker, c->target_name); val = acquire_cred(c, user, password, 1, &hCred); if (val != GSMERR_OK) errx(1, "failed to acquire_cred: %d", (int)val); val = build_context(c, c, GSS_C_REPLAY_FLAG|GSS_C_SEQUENCE_FLAG| GSS_C_INTEG_FLAG|GSS_C_CONF_FLAG| GSS_C_DELEG_FLAG|GSS_C_MUTUAL_FLAG, hCred, &clientC, &serverC, &delegCred); if (val == GSMERR_OK) { test_token(c, clientC, c, serverC, wrap_ext); toast_resource(c, clientC); toast_resource(c, serverC); if (delegCred) toast_resource(c, delegCred); } else { warnx("build_context failed: %d", (int)val); } /* * */ val = build_context(c, c, GSS_C_INTEG_FLAG|GSS_C_CONF_FLAG, hCred, &clientC, &serverC, &delegCred); if (val == GSMERR_OK) { test_token(c, clientC, c, serverC, wrap_ext); toast_resource(c, clientC); toast_resource(c, serverC); if (delegCred) toast_resource(c, delegCred); } else { warnx("build_context failed: %d", (int)val); } toast_resource(c, hCred); } /* * Build contexts though all entries in each lists, including the * step from the last entry to the first, ie treat the list as a * circle. * * Only follow the delegated credential, but test "all" * flags. (XXX only do deleg|mutual right now. */ printf("\"All\" permutation tests\n"); for (i = 0; i < num_list; i++) { int32_t hCred, val, delegCred = 0; int32_t clientC = 0, serverC = 0; struct client *client, *server; p = list[i]; client = get_client(p[0]); val = acquire_cred(client, user, password, 1, &hCred); if (val != GSMERR_OK) errx(1, "failed to acquire_cred: %d", (int)val); for (j = 1; j < num_clients + 1; j++) { server = get_client(p[j % num_clients]); if (server->target_name == NULL) break; for (k = 1; k < j; k++) printf("\t"); printf("%s -> %s\n", client->moniker, server->moniker); val = build_context(client, server, GSS_C_REPLAY_FLAG|GSS_C_SEQUENCE_FLAG| GSS_C_INTEG_FLAG|GSS_C_CONF_FLAG| GSS_C_DELEG_FLAG|GSS_C_MUTUAL_FLAG, hCred, &clientC, &serverC, &delegCred); if (val != GSMERR_OK) { warnx("build_context failed: %d", (int)val); break; } val = test_token(client, clientC, server, serverC, wrap_ext); if (val) break; toast_resource(client, clientC); toast_resource(server, serverC); if (!delegCred) { warnx("no delegated cred on %s", server->moniker); break; } toast_resource(client, hCred); hCred = delegCred; client = server; } if (hCred) toast_resource(client, hCred); } /* * Close all connections to clients */ out: printf("sending goodbye and waiting for log sockets\n"); for (i = 0; i < num_clients; i++) { goodbye(clients[i]); if (clients[i]->logsock) { #ifdef ENABLE_PTHREAD_SUPPORT pthread_join(&clients[i]->thr, NULL); #else waitpid(clients[i]->child, NULL, 0); #endif } } printf("done\n"); return 0; }
JNIEXPORT void JNICALL Java_edu_cornell_vision_hadoop_HadoopPythonMRJob_00024Map_mapper_1init (JNIEnv * env, jobject thisObj, jlong impl, jobject context, jstring user_module, jstring mapper_class_name) { struct MapperImpl * ptr = (struct MapperImpl*)impl; PyObject * main_module = NULL; //borrowed PyObject * sys = NULL; //new PyObject * path = NULL; //new PyObject * dot_string = NULL; //new PyObject * module = NULL; //new PyObject * module_contents = NULL; //borrowed PyObject * mapper_class = NULL; //borrowed PyObject * mapper_object = NULL; PyObject * loads_function = NULL; //borrowed PyObject * dumps_function = NULL; //borrowed PyObject * result = NULL; //new PyObject * mapper_context = NULL; const char * user_module_char = NULL; const char * mapper_class_char = NULL; PyObject * faulthandler_enable_retval = NULL; //new PyObject * faulthandler_disable_retval = NULL; //new HANDLE_JAVA(ptr->Text = (*env)->FindClass(env, "org/apache/hadoop/io/Text")) HANDLE_JAVA(ptr->Text_getBytes = (*env)->GetMethodID(env, ptr->Text, "getBytes", "()[B")); HANDLE_JAVA(ptr->Text_getLength = (*env)->GetMethodID(env, ptr->Text, "getLength", "()I")); Py_SetProgramName("Mapper"); #ifdef FAULTHANDLER HANDLE_PYTHON(ptr->faulthandler = PyImport_ImportModule("faulthandler"), "import faulthandler") #else ptr->faulthandler = Py_None; Py_INCREF(ptr->faulthandler); #endif HANDLE_PYTHON(main_module = PyImport_AddModule("__main__"), "import __main__") HANDLE_PYTHON(sys = PyImport_ImportModule("sys"), "import sys") HANDLE_PYTHON(path = PyObject_GetAttrString(sys, "path"), "get sys.path") HANDLE_PYTHON(dot_string = PyString_FromString("."), "make . string") if (PyList_Append(path, dot_string) < 0) { raise_python_exception (env, "append ."); goto failure; } HANDLE_JAVA(user_module_char = (*env)->GetStringUTFChars(env, user_module, 0)) module = PyImport_ImportModule (user_module_char); HANDLE_JAVA((*env)->ReleaseStringUTFChars(env, user_module, user_module_char)) if (!module) { raise_python_exception (env, "import module"); goto failure; } HANDLE_PYTHON(module_contents = PyModule_GetDict (module), "get module contents"); if (!PyDict_GetItemString (module_contents, "Context")) { if (PyType_Ready(&Context_type) < 0) { raise_python_exception (env, "mapper context not ready"); goto failure; } Py_INCREF(&Context_type); if (PyModule_AddObject (module, "Context", (PyObject*)&Context_type) < 0) { raise_python_exception (env, "add context"); goto failure; } } if (!PyDict_GetItemString (module_contents, "Counter")) { if (PyType_Ready(&Counter_type) < 0) { raise_python_exception (env, "counter not ready"); goto failure; } Py_INCREF(&Counter_type); if (PyModule_AddObject (module, "Counter", (PyObject*)&Counter_type) < 0) { raise_python_exception (env, "add counter"); goto failure; } } HANDLE_JAVA(mapper_class_char = (*env)->GetStringUTFChars(env, mapper_class_name, 0)) mapper_class = PyDict_GetItemString (module_contents, mapper_class_char); HANDLE_JAVA((*env)->ReleaseStringUTFChars(env, mapper_class_name, mapper_class_char)) if (!mapper_class) { PyErr_SetString(PyExc_RuntimeError, "mapper not found"); raise_python_exception (env, "get mapper"); goto failure; } HANDLE_PYTHON(mapper_object = PyObject_CallObject (mapper_class, NULL), "create mapper") ptr->mapper = mapper_object; HANDLE_PYTHON(loads_function = PyObject_GetAttrString (mapper_object, "loads"), "get mapper loads"); ptr->loads = loads_function; HANDLE_PYTHON(dumps_function = PyObject_GetAttrString (mapper_object, "dumps"), "get mapper dumps"); ptr->dumps = dumps_function; HANDLE_PYTHON (mapper_context = build_context (env, context, ptr->dumps, ptr->faulthandler), "build map context") #ifdef FAULTHANDLER HANDLE_PYTHON(faulthandler_enable_retval = PyObject_CallMethod(ptr->faulthandler, "enable", NULL), "enable faulthandler"); #endif HANDLE_PYTHON(result = PyObject_CallMethod (mapper_object, "setup", "O", mapper_context), "call mapper setup") #ifdef FAULTHANDLER HANDLE_PYTHON(faulthandler_disable_retval = PyObject_CallMethod(ptr->faulthandler, "disable", NULL), "disable faulthandler"); #endif failure: Py_XDECREF(faulthandler_enable_retval); Py_XDECREF(faulthandler_disable_retval); Py_XDECREF(mapper_context); Py_XDECREF(sys); Py_XDECREF(path); Py_XDECREF(dot_string); Py_XDECREF(module); Py_XDECREF(result); }
/// general use constructor crypto_asym(user_interaction & ui) : mem_ui(ui) { build_context(); has_signatories = false; };