Skip to content

Commit

Permalink
修正无法删除频道的问题
Browse files Browse the repository at this point in the history
修正在特定情况下会死锁的问题
  • Loading branch information
snowie2000 committed Dec 27, 2024
1 parent e9d72fc commit 5ce89c0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ go 1.22.0
toolchain go1.22.7

require (
github.com/LgoLgo/geentrant v0.1.0
github.com/dlclark/regexp2 v1.10.0
github.com/fopina/net-proxy-httpconnect v0.0.0-20230320235234-11f65320b851
github.com/gin-contrib/sessions v0.0.3
github.com/gin-gonic/gin v1.9.1
github.com/grafov/m3u8 v0.12.0
github.com/imroc/req/v3 v3.46.1
github.com/jamesnetherton/m3u v0.4.0
github.com/jinzhu/gorm v1.9.16
github.com/joho/godotenv v1.3.0
github.com/mojocn/base64Captcha v1.3.6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGB
cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/LgoLgo/geentrant v0.1.0 h1:TDc+joexH02nltk8SU4Ef9jSdnrzGaSD934TvnKrYKg=
github.com/LgoLgo/geentrant v0.1.0/go.mod h1:XacOu/FCdafilV5VnBghrUXgJoySqfR1auJ0bVgg0rk=
github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBKeU+7zCJoLcc=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
Expand Down Expand Up @@ -140,8 +142,6 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/imroc/req/v3 v3.46.1 h1:oahr2hBTb3AaFI4P6jkN0Elj2ZVKJcdQ/IjWqeIKjvc=
github.com/imroc/req/v3 v3.46.1/go.mod h1:weam9gmyb00QnOtu6HXSnk44dNFkIUQb5QdMx13FeUU=
github.com/jamesnetherton/m3u v0.4.0 h1:whEon8Bj6AAtejE7lkhE83qKxyZR6xFkADGcerYDWlA=
github.com/jamesnetherton/m3u v0.4.0/go.mod h1:wiM6FnmepH4gnwvaeBvppddHiTHmy5u/hx7wPa140mA=
github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
Expand Down
3 changes: 1 addition & 2 deletions handler/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ func UpdateChannelHandler(c *gin.Context) {
// check if the parser can provide sub channels
if p, err := plugin.GetPlugin(chParser); err == nil {
if _, ok := p.(plugin.ChannalProvider); ok {
log.Println("update channel: sub channel yes")
channel.HasSubChannel = true
}
}
Expand All @@ -387,7 +386,7 @@ func DeleteChannelHandler(c *gin.Context) {
c.String(http.StatusUnauthorized, "Unauthorized")
return
}
chID, chSubId := getChannelNumbers(c.PostForm("id"))
chID, chSubId := getChannelNumbers(c.Query("id"))
if chID == 0 {
c.String(http.StatusInternalServerError, "empty id")
return
Expand Down
9 changes: 5 additions & 4 deletions service/m3u8cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package service
import (
"log"

"github.com/LgoLgo/geentrant"
"github.com/snowie2000/livetv/global"
"github.com/snowie2000/livetv/model"
"github.com/snowie2000/livetv/plugin"
)

var updateConcurrent = make(chan bool, 2) // allow up to 2 urls to be updated simultaneously
var updateConcurrent = &greetrant.RecursiveMutex{}

func LoadChannelCache() {
channels, err := GetAllChannel()
Expand All @@ -35,9 +36,9 @@ func UpdateSubChannels(parentChannel *model.Channel, liveInfo *model.LiveInfo, P
}

func UpdateURLCacheSingle(channel *model.Channel, bUpdateStatus bool) (*model.LiveInfo, error) {
updateConcurrent <- true
updateConcurrent.Lock()
defer func() {
<-updateConcurrent
updateConcurrent.Unlock()
}()
log.Println("caching", channel.URL)
liveInfo, err := RealLiveM3U8(channel.URL, channel.ProxyUrl, channel.Parser)
Expand All @@ -53,8 +54,8 @@ func UpdateURLCacheSingle(channel *model.Channel, bUpdateStatus bool) (*model.Li
}
log.Println(channel.URL, "cached")

UpdateSubChannels(channel, liveInfo, channel.Parser, bUpdateStatus)
InvalidateChannelCache(channel.ChannelID)
UpdateSubChannels(channel, liveInfo, channel.Parser, bUpdateStatus)
}
return liveInfo, err
}
Expand Down

0 comments on commit 5ce89c0

Please sign in to comment.