static int decode_locker(void **p, void *end, struct ceph_locker *locker) { u8 struct_v; u32 len; char *s; int ret; ret = ceph_start_decoding(p, end, 1, "locker_id_t", &struct_v, &len); if (ret) return ret; ceph_decode_copy(p, &locker->id.name, sizeof(locker->id.name)); s = ceph_extract_encoded_string(p, end, NULL, GFP_NOIO); if (IS_ERR(s)) return PTR_ERR(s); locker->id.cookie = s; ret = ceph_start_decoding(p, end, 1, "locker_info_t", &struct_v, &len); if (ret) return ret; *p += sizeof(struct ceph_timespec); /* skip expiration */ ceph_decode_copy(p, &locker->info.addr, sizeof(locker->info.addr)); ceph_decode_addr(&locker->info.addr); len = ceph_decode_32(p); *p += len; /* skip description */ dout("%s %s%llu cookie %s addr %s\n", __func__, ENTITY_NAME(locker->id.name), locker->id.cookie, ceph_pr_addr(&locker->info.addr.in_addr)); return 0; }
/** * ceph_cls_break_lock - release rados lock for object for specified client * @oid, @oloc: object to lock * @lock_name: the name of the lock * @cookie: user-defined identifier for this instance of the lock * @locker: current lock owner */ int ceph_cls_break_lock(struct ceph_osd_client *osdc, struct ceph_object_id *oid, struct ceph_object_locator *oloc, char *lock_name, char *cookie, struct ceph_entity_name *locker) { int break_op_buf_size; int name_len = strlen(lock_name); int cookie_len = strlen(cookie); struct page *break_op_page; void *p, *end; int ret; break_op_buf_size = name_len + sizeof(__le32) + cookie_len + sizeof(__le32) + sizeof(u8) + sizeof(__le64) + CEPH_ENCODING_START_BLK_LEN; if (break_op_buf_size > PAGE_SIZE) return -E2BIG; break_op_page = alloc_page(GFP_NOIO); if (!break_op_page) return -ENOMEM; p = page_address(break_op_page); end = p + break_op_buf_size; /* encode cls_lock_break_op struct */ ceph_start_encoding(&p, 1, 1, break_op_buf_size - CEPH_ENCODING_START_BLK_LEN); ceph_encode_string(&p, end, lock_name, name_len); ceph_encode_copy(&p, locker, sizeof(*locker)); ceph_encode_string(&p, end, cookie, cookie_len); dout("%s lock_name %s cookie %s locker %s%llu\n", __func__, lock_name, cookie, ENTITY_NAME(*locker)); ret = ceph_osdc_call(osdc, oid, oloc, "lock", "break_lock", CEPH_OSD_FLAG_WRITE, break_op_page, break_op_buf_size, NULL, NULL); dout("%s: status %d\n", __func__, ret); __free_page(break_op_page); return ret; }
static int monmap_show(struct seq_file *s, void *p) { int i; struct ceph_client *client = s->private; if (client->monc.monmap == NULL) return 0; seq_printf(s, "epoch %d\n", client->monc.monmap->epoch); for (i = 0; i < client->monc.monmap->num_mon; i++) { struct ceph_entity_inst *inst = &client->monc.monmap->mon_inst[i]; seq_printf(s, "\t%s%lld\t%s\n", ENTITY_NAME(inst->name), ceph_pr_addr(&inst->addr.in_addr)); } return 0; }
// Process all savepoints void SavePoints::process() { while (_savepoints.size() > 0 && getFlags()->isGameRunning) { SavePoint savepoint = pop(); // If this is a data savepoint, update the entity // otherwise, execute the callback if (!updateEntityFromData(savepoint)) { // Call requested callback Entity::Callback *callback = getCallback(savepoint.entity1); if (callback && callback->isValid()) { debugC(8, kLastExpressDebugLogic, "Savepoint: entity1=%s, action=%s, entity2=%s", ENTITY_NAME(savepoint.entity1), ACTION_NAME(savepoint.action), ENTITY_NAME(savepoint.entity2)); (*callback)(savepoint); } } } }
////////////////////////////////////////////////////////////////////////// // Misc ////////////////////////////////////////////////////////////////////////// bool SavePoints::updateEntityFromData(const SavePoint &savepoint) { for (int i = 0; i < (int)_data.size(); i++) { // Not a data savepoint! if (!_data[i].entity1) return false; // Found our data! if (_data[i].entity1 == savepoint.entity1 && _data[i].action == savepoint.action) { debugC(8, kLastExpressDebugLogic, "Update entity from data: entity1=%s, action=%s, param=%d", ENTITY_NAME(_data[i].entity1), ACTION_NAME(_data[i].action), _data[i].param); // the SavePoint param value is the index of the entity call parameter to update getEntities()->get(_data[i].entity1)->getParamData()->updateParameters(_data[i].param); return true; } } return false; }
void SavePoints::call(EntityIndex entity2, EntityIndex entity1, ActionIndex action, const char *param) const { SavePoint point; point.entity1 = entity1; point.action = action; point.entity2 = entity2; strcpy((char *)&point.param.charValue, param); Entity::Callback *callback = getCallback(entity1); if (callback != NULL && callback->isValid()) { debugC(8, kLastExpressDebugLogic, "Savepoint: entity1=%s, action=%s, entity2=%s, param=%s", ENTITY_NAME(entity1), ACTION_NAME(action), ENTITY_NAME(entity2), param); (*callback)(point); } }
////////////////////////////////////////////////////////////////////////// // Callbacks ////////////////////////////////////////////////////////////////////////// void SavePoints::setCallback(EntityIndex index, Entity::Callback *callback) { if (index >= 40) error("SavePoints::setCallback - attempting to use an invalid entity index. Valid values 0-39, was %d", index); if (!callback || !callback->isValid()) error("SavePoints::setCallback - attempting to set an invalid callback for entity %s", ENTITY_NAME(index)); _callbacks[index] = callback; }
Common::String Objects::Object::toString() { return Common::String::format("{ %s - %d - %d - %d - %d }", ENTITY_NAME(entity), location, cursor, cursor2, location2); }
Common::String Objects::Object::toString() { return Common::String::format("{ %s - %d - %d - %d - %d }", ENTITY_NAME(entity), status, windowCursor, handleCursor, model); }