MiraiForum

    • Register
    • Login
    • Search
    • Popular
    • Recent
    • Unsolved
    • Tags
    • Groups
    • 友情链接

    Solved 询问:key refresh job是否应该在relogin时cancel

    BUG反馈
    2
    4
    130
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ArcticLampyrid
      ArcticLampyrid last edited by

      粗略阅读了下Mirai的代码
      在closeEverythingAndRelogin中launch的key refresh job似乎并不会被cancel
      在重连时相关Content似乎也不会被close & renew
      这是特意为之还是bug?


      heartbeat job等似乎是手动cancel的:
      QQAndroidBotNetworkHandler.kt#L121-L125

          override suspend fun closeEverythingAndRelogin(host: String, port: Int, cause: Throwable?, step: Int) {
              heartbeatJob?.cancel(CancellationException("relogin", cause))
              heartbeatJob?.join()
              _packetReceiverJob?.cancel(CancellationException("relogin", cause))
              _packetReceiverJob?.join()
      

      key refresh job创建后没有保留对Job的引用
      QQAndroidBotNetworkHandler.kt#L270-L283

              launch {
                  while (isActive) {
                      bot.client.wLoginSigInfo.sKey.run {
                          val delay = (expireTime - creationTime).seconds - 5.minutes
                          logger.info { "Scheduled key refresh in ${delay.toHumanReadableString()}." }
                          delay(delay)
                      }
                      runCatching {
                          refreshKeys()
                      }.onFailure {
                          logger.error("Failed to refresh key.", it)
                      }
                  }
              }
      
      1 Reply Last reply Reply Quote 0
      • Karlatemp
        Karlatemp last edited by

        感谢你发现这个问题,这个问题已经在最近的commit中修复了

        ArcticLampyrid 1 Reply Last reply Reply Quote 0
        • ArcticLampyrid
          ArcticLampyrid @Karlatemp last edited by

          @karlatemp 似乎没有push?

          Karlatemp 1 Reply Last reply Reply Quote 0
          • Karlatemp
            Karlatemp @ArcticLampyrid last edited by Karlatemp

            https://github.com/mamoe/mirai/commit/716b8c6129d74dcdcd293ddfc98bb8f2acbe1178

            0 Karlatemp committed to mamoe/mirai
            Reinitialize network before connect server
            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Powered by Mamoe Technologies & NodeBB | 友情链接 | 服务监控 | Contact