void MasterServer::add_chunk(ChunkInfo &chunk_info) { map<string, ChunkInfo>::iterator it = m_chunk_manager.find(chunk_info.id); if(it == m_chunk_manager.end()) { m_chunk_manager.insert(std::make_pair(chunk_info.id, chunk_info)); SLOG_DEBUG("add a new chunk info[chunk_id=%s, ip=%s, port=%d, disk_space=%lld, disk_used=%lld]. total chunk:%d." ,chunk_info.id.c_str() ,chunk_info.ip.c_str() ,chunk_info.port ,chunk_info.disk_space ,chunk_info.disk_used ,m_chunk_manager.size()); } else { it->second = chunk_info; SLOG_DEBUG("update chunk info[chunk_id=%s, ip=%s, port=%d, disk_space=%lld, disk_used=%lld]. total chunk:%d." ,chunk_info.id.c_str() ,chunk_info.ip.c_str() ,chunk_info.port ,chunk_info.disk_space ,chunk_info.disk_used ,m_chunk_manager.size()); } }
Protocol* DownloadProtocolFamily::create_protocol_by_header(ProtocolHeader *header) { int protocol_type = ((DefaultProtocolHeader *)header)->get_protocol_type(); Protocol *protocol = NULL; switch(protocol_type) { case PROTOCOL_REQUEST_SIZE: protocol = (Protocol*)m_request_size_memcache.Alloc(); SLOG_DEBUG("create RequestSize[%x] from m_request_size_memcache", protocol); break; case PROTOCOL_RESPOND_SIZE: protocol = (Protocol*)m_respond_size_memcache.Alloc(); SLOG_DEBUG("create RespondSize[%x] from m_respond_size_memcache", protocol); break; case PROTOCOL_REQUEST_DATA: protocol = (Protocol*)m_request_data_memcache.Alloc(); SLOG_DEBUG("create RequestData[%x] from m_request_data_memcache", protocol); break; case PROTOCOL_RESPOND_DATA: protocol = (Protocol*)m_respond_data_memcache.Alloc(); SLOG_DEBUG("create RespondData[%x] from m_respond_data_memcache", protocol); break; default: break; } return protocol; }
bool TaskManager::on_notify_add_task() { SLOG_DEBUG("Thread[ID=%d,Addr=%x] do task",get_thread_id(), this); string file_name; while(get_task(file_name)) { SLOG_DEBUG("Thread[ID=%d, Addr=%x] receive task=%s", get_thread_id(), this, file_name.c_str()); if(send_get_filesize_task(file_name) == false) SLOG_ERROR("sent get_file_size protocol failed. file_name=%s", file_name.c_str()); } return true; }
HANDLE_RESULT MasterServer::on_timeout(int fd) { //检查超时的任务 SLOG_DEBUG("master on_timeout,check all task..."); remove_saving_task_timeout(); return HANDLE_OK; }
bool MasterServer::on_socket_handler_accpet(SocketHandle socket_handle) { SLOG_DEBUG("Thread[ID=%d] handle new socket. fd=%d", get_thread_id(), socket_handle); //Add your code to handle new socket //////////////////////////////////// return true; }
/*! * Создание или повторная инициализация вкладки канала. * * \param id Идентификатор канала. * \param create \b true если необходимо создать канал. * \param show \b true если необходимо выбрать эту вкладку. * * \return Возвращает указатель на вкладку или 0 в случае ошибки. */ ChannelBaseTab *TabWidget::channelTab(const QByteArray &id, bool create, bool show) { SLOG_DEBUG("id =" << SimpleID::encode(id) << "create =" << create << "show =" << show); if (!Channel::isCompatibleId(id)) return 0; ChannelBaseTab *tab = 0; if (m_channels.contains(id)) { tab = m_channels.value(id); create = false; } ClientChannel channel = ChatClient::channels()->get(id); if (!channel) { if (!m_prefetch.contains(id)) m_prefetch.append(id); return 0; } if (create) { if (channel->type() == SimpleID::UserId) tab = new PrivateTab(channel, this); else if (channel->type() == SimpleID::ChannelId) tab = new ChannelTab(channel, this); if (tab) { m_channels[id] = tab; tab->setOnline(); addTab(tab, tab->icon(), channel->name()); connect(tab, SIGNAL(actionTriggered(bool)), SLOT(openTab())); if (channel->type() == SimpleID::ChannelId && isAutoPin(channel->id())) tab->pin(); if (m_autoPin.contains(id)) { m_autoPin.removeAll(id); tab->pin(); emit pinned(tab); } } closePage(PROGRESS_TAB); closePage(WELCOME_TAB); } if (show && tab) setCurrentIndex(indexOf(tab)); return tab; }
void DownloadProtocolFamily::destroy_protocol(Protocol* protocol) { if(protocol == NULL) return; DefaultProtocolHeader *header = (DefaultProtocolHeader *)protocol->get_protocol_header(); switch(header->get_protocol_type()) { case PROTOCOL_REQUEST_SIZE: { SLOG_DEBUG("free DownloadRequest[%x] to m_request_size_memcache", protocol); RequestSize *temp_protocol = (RequestSize*)protocol; m_request_size_memcache.Free(temp_protocol); break; } case PROTOCOL_RESPOND_SIZE: { SLOG_DEBUG("free RespondSize[%x] to m_respond_size_memcache", protocol); RespondSize *temp_protocol = (RespondSize*)protocol; m_respond_size_memcache.Free(temp_protocol); break; } case PROTOCOL_REQUEST_DATA: { SLOG_DEBUG("free RequestData[%x] to m_request_data_memcache", protocol); RequestData *temp_protocol = (RequestData*)protocol; m_request_data_memcache.Free(temp_protocol); break; } case PROTOCOL_RESPOND_DATA: { SLOG_DEBUG("free RespondData[%x] to m_respond_data_memcache", protocol); RespondData *temp_protocol = (RespondData*)protocol; m_respond_data_memcache.Free(temp_protocol); break; } default: break; } }
int main (int argc, char **argv) { syslog_print_init("LFQ"); SLOG_EMERG("%s(%d): %s", __FUNCTION__, __LINE__, "ABCDES"); SLOG_ALERT("%s(%d): %s", __FUNCTION__, __LINE__, "ABCDES"); // syslog_set_level(LOG_EMERG); SLOG_CRIT("%s(%d): %s", __FUNCTION__, __LINE__, "ABCDES"); SLOG_ERR("%s(%d): %s", __FUNCTION__, __LINE__, "ABCDES"); SLOG_NOTICE("%s(%d): %s", __FUNCTION__, __LINE__, "ABCDES"); SLOG_WARNING("%s(%d): %s", __FUNCTION__, __LINE__, "ABCDES"); SLOG_INFO("%s(%d): %s", __FUNCTION__, __LINE__, "ABCDES"); SLOG_DEBUG("%s(%d): %s", __FUNCTION__, __LINE__, "ABCDES"); CLOG_DEBUG("%s(%d): %s", __FUNCTION__, __LINE__, "ABCDES"); syslog_print_close(); }
bool MasterServer::remove_saving_task_timeout() { int now = (int)time(NULL); list<TimeFid>::iterator it; while(m_time_fid_list.size() > 0) { it = m_time_fid_list.end(); --it; if(now-it->insert_time < m_saving_task_timeout_sec) break; SLOG_DEBUG("saving task timeout and delete:fid=%s, instert_time=%d, now=%d.", it->fid.c_str(), it->insert_time, now); m_saving_task_map.erase(it->fid); m_time_fid_list.erase(it); } return true; }
qint64 ServiceThread::add(IServiceTask *task) { Q_ASSERT(task); SLOG_DEBUG(currentThread() << "task =" << task); task->setCounter(++m_counter); if (!isReady()) { m_mutex.lock(); m_queue.enqueue(task); m_mutex.unlock(); } else QMetaObject::invokeMethod(m_list, "append", Qt::QueuedConnection, Q_ARG(IServiceTask*, task)); return m_counter; }
void CVisionPipeline::ComputeFaceTrackArea (CIplImage &image) { if (!m_trackFace) return; int cx, cy; float sx,sy; CvRect curBox; CvSeq *face = cvHaarDetectObjects( image.ptr(), m_faceCascade, m_storage, 1.1, 2, CV_HAAR_DO_CANNY_PRUNING, cvSize(65, 65) ); if (face->total>0) { CvRect* faceRect = (CvRect*) cvGetSeqElem(face, 0); SLOG_DEBUG("face detected: location (%d, %d) size (%d, %d)", faceRect->x, faceRect->y, faceRect->width, faceRect->height); m_trackArea.GetBoxImg(&image, curBox); // Compute new face area size averaging with old area making it wider (horizontaly) sx= ((float) faceRect->width * 0.15f + (float) curBox.width * 0.9f); sy= ((float) faceRect->height * 0.1f + (float) curBox.height * 0.9f); m_trackArea.SetSizeImg(&image, (int)sx, (int)sy); // Computer new face position cx= (int) ((float)(faceRect->x+faceRect->width/2) * 0.5f + (float)(curBox.x+curBox.width/2) * 0.5f); cy= (int) ((float)(faceRect->y+faceRect->height/2) * 0.5f + (float)(curBox.y+curBox.height/2) * 0.5f); m_trackArea.SetCenterImg (&image, cx, cy); m_waitTime.Reset(); m_trackAreaTimeout.Reset(); } cvClearMemStorage(m_storage); }
bool TaskManager::on_socket_handler_accpet(SocketHandle socket_handle) { SLOG_DEBUG("server app on socket handle accpet. fd=%d", socket_handle); return true; }
bool MTServerAppFramework::on_socket_handler_accpet(SocketHandle socket_handle) { SLOG_DEBUG("server app on socket handle accpet. fd=%d", socket_handle); return true; }
//响应文件信息查询包 void MasterServer::on_file_info_req(SocketHandle socket_handle, Protocol *protocol) { SFSProtocolFamily* protocol_family = (SFSProtocolFamily*)get_protocol_family(); ProtocolFileInfo *protocol_fileinfo = (ProtocolFileInfo *)protocol_family->create_protocol(PROTOCOL_FILE_INFO); assert(protocol_fileinfo != NULL); ProtocolFileInfoReq *protocol_file_info_req = (ProtocolFileInfoReq *)protocol; const string& fid = protocol_file_info_req->get_fid(); bool query_chunkpath = protocol_file_info_req->get_query_chunkpath(); SLOG_INFO("receive file_info_req protocol.fd=%d, fid=%s, query=%d", socket_handle, fid.c_str(), query_chunkpath?1:0); FileInfo& file_info = protocol_fileinfo->get_fileinfo(); if(get_fileinfo(fid, file_info)) //已经存在 { SLOG_DEBUG("find file_info succ: fid=%s, size=%d.", fid.c_str(), file_info.size); int i; for(i=0; i<file_info.get_chunkpath_count(); ++i) { ChunkPath &chunk_path = file_info.get_chunkpath(i); SLOG_DEBUG("chunk[%d]:id=%s, ip=%s, port=%d, index=%d, offset=%d." ,i, chunk_path.id.c_str(), chunk_path.ip.c_str(), chunk_path.port, chunk_path.index, chunk_path.offset); } file_info.result = FileInfo::RESULT_SUCC; } else if(find_saving_task(fid)) //正在保存 { SLOG_DEBUG("fid=%s is saving.", fid.c_str()); file_info.result = FileInfo::RESULT_SAVING; } else if(query_chunkpath) //分配chunk { file_info.fid = fid; file_info.name = ""; //无效 file_info.size = 0; //无效 ChunkPath chunk_path; ChunkInfo chunk_info; if(get_chunk(chunk_info)) //分配chunk { file_info.result = FileInfo::RESULT_CHUNK; chunk_path.id = chunk_info.id; chunk_path.ip = chunk_info.ip; chunk_path.port = chunk_info.port; chunk_path.index = 0; //无效 chunk_path.offset = 0; //无效 file_info.add_chunkpath(chunk_path); add_saving_task(fid); SLOG_DEBUG("dispatch chunk[id=%s,ip=%s,port=%d] for fid=%s.", chunk_info.id.c_str(), chunk_info.ip.c_str(), chunk_info.port, fid.c_str()); } else { SLOG_WARN("get chunk failed for fid=%s.", fid.c_str()); file_info.result = FileInfo::RESULT_FAILED; } } else //失败 { SLOG_WARN("get file_info failed for fid=%s.", fid.c_str()); file_info.result = FileInfo::RESULT_FAILED; } if(!send_protocol(socket_handle, protocol_fileinfo)) { SLOG_ERROR("send file_info protocol failed. fd=%d, fid=%s.", socket_handle, fid.c_str()); protocol_family->destroy_protocol(protocol_fileinfo); } }
void PreviewCore::add(const ChatId &id, const QList<QUrl> &urls) { SLOG_DEBUG(id.toBase32() << urls); m_storage->add(id, urls); }