| 333 | } |
| 334 | |
| 335 | void CRegister::CProtocol::SendDeleteIfRegistered(bool Shutdown) |
| 336 | { |
| 337 | { |
| 338 | const CLockScope LockScope(m_pShared->m_Lock); |
| 339 | const bool ShouldSendDelete = m_pShared->m_LatestResponseStatus == STATUS_OK; |
| 340 | m_pShared->m_LatestResponseStatus = STATUS_NONE; |
| 341 | if(!ShouldSendDelete) |
| 342 | return; |
| 343 | } |
| 344 | |
| 345 | char aAddress[64]; |
| 346 | str_format(aAddress, sizeof(aAddress), "%sconnecting-address.invalid:%d", ProtocolToScheme(m_Protocol), m_pParent->m_ServerPort); |
| 347 | |
| 348 | char aSecret[UUID_MAXSTRSIZE]; |
| 349 | FormatUuid(m_pParent->m_Secret, aSecret, sizeof(aSecret)); |
| 350 | |
| 351 | std::shared_ptr<CHttpRequest> pDelete = HttpPost(m_pParent->m_pConfig->m_SvRegisterUrl, (const unsigned char *)"", 0); |
| 352 | pDelete->HeaderString("Action", "delete"); |
| 353 | pDelete->HeaderString("Address", aAddress); |
| 354 | pDelete->HeaderString("Secret", aSecret); |
| 355 | for(int i = 0; i < m_pParent->m_NumExtraHeaders; i++) |
| 356 | { |
| 357 | pDelete->Header(m_pParent->m_aaExtraHeaders[i]); |
| 358 | } |
| 359 | pDelete->LogProgress(HTTPLOG::FAILURE); |
| 360 | pDelete->IpResolve(ProtocolToIpresolve(m_Protocol)); |
| 361 | if(Shutdown) |
| 362 | { |
| 363 | // On shutdown, wait at most 1 second for the delete requests. |
| 364 | pDelete->Timeout(CTimeout{1000, 1000, 0, 0}); |
| 365 | } |
| 366 | log_info(ProtocolToSystem(m_Protocol), "deleting..."); |
| 367 | m_pParent->m_pHttp->Run(pDelete); |
| 368 | } |
| 369 | |
| 370 | CRegister::CProtocol::CProtocol(CRegister *pParent, int Protocol) : |
| 371 | m_pParent(pParent), |
no test coverage detected