aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-03 02:19:54 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-03 02:19:54 +0200
commite4c683ece5044cee42b670bf04031429e426eddb (patch)
tree781013530db54fee7b81a9e33386b2cd4f4a93be
parentd131d0dec6a6c7f0af3511bd908cda8a3d910237 (diff)
downloadfeed2imap-go-e4c683ece5044cee42b670bf04031429e426eddb.tar.gz
feed2imap-go-e4c683ece5044cee42b670bf04031429e426eddb.tar.bz2
feed2imap-go-e4c683ece5044cee42b670bf04031429e426eddb.zip
Rename from 'client' to 'cl'
Diffstat (limited to '')
-rw-r--r--internal/imap/client.go10
-rw-r--r--internal/imap/cmds.go12
-rw-r--r--internal/imap/commando.go16
-rw-r--r--internal/imap/folder.go10
-rw-r--r--internal/imap/imap.go4
5 files changed, 26 insertions, 26 deletions
diff --git a/internal/imap/client.go b/internal/imap/client.go
index 731e35b..783acf6 100644
--- a/internal/imap/client.go
+++ b/internal/imap/client.go
@@ -23,17 +23,17 @@ type Client struct {
nextFreeIndex int
}
-func (client *Client) Disconnect() {
- if client != nil {
- client.stopCommander()
+func (cl *Client) Disconnect() {
+ if cl != nil {
+ cl.stopCommander()
connected := false
- for _, conn := range client.connections {
+ for _, conn := range cl.connections {
connected = conn.disconnect() || connected
}
if connected {
- log.Print("Disconnected from ", client.host)
+ log.Print("Disconnected from ", cl.host)
}
}
}
diff --git a/internal/imap/cmds.go b/internal/imap/cmds.go
index 7c99fc3..3cfb61d 100644
--- a/internal/imap/cmds.go
+++ b/internal/imap/cmds.go
@@ -8,8 +8,8 @@ func (cmd ensureCommando) execute(conn *connection) error {
return conn.ensureFolder(cmd.folder)
}
-func (client *Client) EnsureFolder(folder Folder) error {
- return client.commander.execute(ensureCommando{folder})
+func (cl *Client) EnsureFolder(folder Folder) error {
+ return cl.commander.execute(ensureCommando{folder})
}
type addCommando struct {
@@ -21,8 +21,8 @@ func (cmd addCommando) execute(conn *connection) error {
return conn.putMessages(cmd.folder, cmd.messages)
}
-func (client *Client) PutMessages(folder Folder, messages []string) error {
- return client.commander.execute(addCommando{folder, messages})
+func (cl *Client) PutMessages(folder Folder, messages []string) error {
+ return cl.commander.execute(addCommando{folder, messages})
}
type replaceCommando struct {
@@ -37,6 +37,6 @@ func (cmd replaceCommando) execute(conn *connection) error {
return conn.replace(cmd.folder, cmd.header, cmd.value, cmd.newContent, cmd.force)
}
-func (client *Client) Replace(folder Folder, header, value, newContent string, force bool) error {
- return client.commander.execute(replaceCommando{folder, header, value, newContent, force})
+func (cl *Client) Replace(folder Folder, header, value, newContent string, force bool) error {
+ return cl.commander.execute(replaceCommando{folder, header, value, newContent, force})
}
diff --git a/internal/imap/commando.go b/internal/imap/commando.go
index 348c724..1ba4ed3 100644
--- a/internal/imap/commando.go
+++ b/internal/imap/commando.go
@@ -40,29 +40,29 @@ func executioner(conn *connection, pipe <-chan execution, done <-chan struct{})
}
}
-func (client *Client) startCommander() {
- if client.commander != nil {
+func (cl *Client) startCommander() {
+ if cl.commander != nil {
return
}
pipe := make(chan execution, maxPipeDepth)
done := make(chan struct{})
- client.commander = &commander{client, pipe, done}
+ cl.commander = &commander{cl, pipe, done}
- for _, conn := range client.connections {
+ for _, conn := range cl.connections {
if conn != nil {
go executioner(conn, pipe, done)
}
}
}
-func (client *Client) stopCommander() {
- if client.commander == nil {
+func (cl *Client) stopCommander() {
+ if cl.commander == nil {
return
}
- close(client.commander.done)
+ close(cl.commander.done)
- client.commander = nil
+ cl.commander = nil
}
diff --git a/internal/imap/folder.go b/internal/imap/folder.go
index 1f4e0bf..e845862 100644
--- a/internal/imap/folder.go
+++ b/internal/imap/folder.go
@@ -21,13 +21,13 @@ func (f Folder) Append(other Folder) Folder {
}
}
-func (client *Client) folderName(path []string) Folder {
+func (cl *Client) folderName(path []string) Folder {
return Folder{
- strings.Join(path, client.delimiter),
- client.delimiter,
+ strings.Join(path, cl.delimiter),
+ cl.delimiter,
}
}
-func (client *Client) NewFolder(path []string) Folder {
- return client.toplevel.Append(client.folderName(path))
+func (cl *Client) NewFolder(path []string) Folder {
+ return cl.toplevel.Append(cl.folderName(path))
}
diff --git a/internal/imap/imap.go b/internal/imap/imap.go
index f8c8632..63684a8 100644
--- a/internal/imap/imap.go
+++ b/internal/imap/imap.go
@@ -30,13 +30,13 @@ func newImapClient(url *URL, forceTls bool) (*imapClient.Client, error) {
return c, nil
}
-func (client *Client) connect(url *URL, forceTls bool) (*connection, error) {
+func (cl *Client) connect(url *URL, forceTls bool) (*connection, error) {
c, err := newImapClient(url, forceTls)
if err != nil {
return nil, err
}
- conn := client.createConnection(c)
+ conn := cl.createConnection(c)
if !forceTls {
if err = conn.startTls(); err != nil {
d>Lars Hjemli1-3/+7 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-16Make repo header a link to summary pageLars Hjemli2-1/+12 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-16Move cgit_print_date into ui-shared, reuse in ui-summaryLars Hjemli4-20/+24 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-16Add ui-commit.c + misc ui cleanupsLars Hjemli9-19/+140 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-15Add a common commit parserLars Hjemli3-63/+75 Make a better commit parser, replacing the ugly one in ui-log.c Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-14Add simple pager to log pageLars Hjemli4-6/+37 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-13Add separate makefile-rule to clear current cacheLars Hjemli1-2/+4 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-13Remove implementation details from READMELars Hjemli1-53/+34 Let README describe the "bigger picture" instead. Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-13Small layout adjustments to summary and blob viewLars Hjemli3-5/+13 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-13Add display of tree content w/ui-tree.cLars Hjemli9-8/+113 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-12cache_lock: do xstrdup/free on lockfileLars Hjemli1-1/+2 Since fmt() uses 8 alternating static buffers, and cache_lock might call cache_create_dirs() multiple times, which in turn might call fmt() twice, after four iterations lockfile would be overwritten by a cachedirectory path. In worst case, this could cause the cachedirectory to be unlinked and replaced by a cachefile. Fix: use xstrdup() on the result from fmt() before assigning to lockfile, and call free(lockfile) before exit. Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Don't truncate valid cachefilesLars Hjemli3-4/+16 An embarrassing thinko in cgit_check_cache() would truncate valid cachefiles in the following situation: 1) process A notices a missing/expired cachefile 2) process B gets scheduled, locks, fills and unlocks the cachefile 3) process A gets scheduled, locks the cachefile, notices that the cachefile now exist/is not expired anymore, and continues to overwrite it with an empty lockfile. Thanks to Linus for noticing (again). Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Move global variables + callback functions into shared.cLars Hjemli4-82/+86 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Move functions for generic object output into ui-view.cLars Hjemli4-34/+43 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Move log-functions into ui-log.cLars Hjemli5-111/+121 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Move repo summary functions into ui-summary.cLars Hjemli4-47/+59 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Move functions for repolist output into ui-repolist.cLars Hjemli5-70/+90 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Move common output-functions into ui-shared.cLars Hjemli4-82/+99 While at it, replace the cgit_[lib_]error constants with a proper function Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Rename config.c to parsing.c + move cgit_parse_query from cgit.c to parsing.cLars Hjemli4-28/+29 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Avoid infinite loops in caching layerLars Hjemli3-14/+31 Add a global variable, cgit_max_lock_attemps, to avoid the possibility of infinite loops when failing to acquire a lockfile. This could happen on broken setups or under crazy server load. Incidentally, this also fixes a lurking bug in cache_lock() where an uninitialized returnvalue was used. Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Let 'make install' clear all cachefilesLars Hjemli1-0/+2 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-11Fix cache algorithm loopholeLars Hjemli3-11/+16 This closes the door for unneccessary calls to cgit_fill_cache(). Noticed by Linus. Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-10Add version identifier in generated filesLars Hjemli2-9/+14 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-10Add license file and copyright noticesLars Hjemli5-0/+372 Signed-off-by: Lars Hjemli <hjemli@gmail.com> 2006-12-10Add caching infrastructureLars Hjemli9-28/+353 This enables internal caching of page output. Page requests are split into four groups: 1) repo listing (front page) 2) repo summary 3) repo pages w/symbolic references in query string 4) repo pages w/constant sha1's in query string Each group has a TTL specified in minutes. When a page is requested, a cached filename is stat(2)'ed and st_mtime is compared to time(2). If TTL has expired (or the file didn't exist), the cached file is regenerated. When generating a cached file, locking is used to avoid parallell processing of the request. If multiple processes tries to aquire the same lock, the ones who fail to get the lock serves the (expired) cached file. If the cached file don't exist, the process instead calls sched_yield(2) before restarting the request processing. Signed-off-by: Lars Hjemli <hjemli@gmail.com>