Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
72eb5fa4
Commit
72eb5fa4
authored
Oct 25, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
X switch to fsnotify stub that works via polling without unsafe and x/sys
Still crashes
parent
71b70602
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
145 additions
and
1 deletion
+145
-1
wcfs/vendor/lab.nexedi.com/kirr/neo/go/zodb/storage/fs1/filestorage.go
...ab.nexedi.com/kirr/neo/go/zodb/storage/fs1/filestorage.go
+2
-1
wcfs/vendor/lab.nexedi.com/kirr/neo/go/zodb/storage/fs1/internal/fsnotify-stub/fsnotify/fsnotify.go
...b/storage/fs1/internal/fsnotify-stub/fsnotify/fsnotify.go
+143
-0
No files found.
wcfs/vendor/lab.nexedi.com/kirr/neo/go/zodb/storage/fs1/filestorage.go
View file @
72eb5fa4
...
...
@@ -77,7 +77,8 @@ import (
"lab.nexedi.com/kirr/go123/xerr"
"github.com/fsnotify/fsnotify"
//"github.com/fsnotify/fsnotify"
"lab.nexedi.com/kirr/neo/go/zodb/storage/fs1/internal/fsnotify-stub/fsnotify"
"github.com/pkg/errors"
)
...
...
wcfs/vendor/lab.nexedi.com/kirr/neo/go/zodb/storage/fs1/internal/fsnotify-stub/fsnotify/fsnotify.go
0 → 100644
View file @
72eb5fa4
// Package fsnotify implements github.com/fsnotify/fsnotify interface via polling.
package
fsnotify
import
(
"context"
"errors"
"os"
"time"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xsync"
//"fmt"
)
var
ErrEventOverflow
=
errors
.
New
(
"fsnotify queue overflow"
)
type
Op
uint32
const
(
Create
Op
=
1
<<
iota
Write
Remove
Rename
Chmod
)
type
Event
struct
{
Name
string
Op
Op
}
type
Watcher
struct
{
Events
chan
Event
Errors
chan
error
watchCancel
func
()
watchGroup
*
xsync
.
WorkGroup
}
func
NewWatcher
()
(
*
Watcher
,
error
)
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
wg
:=
xsync
.
NewWorkGroup
(
ctx
)
return
&
Watcher
{
Events
:
make
(
chan
Event
),
// XXX no buf?
Errors
:
make
(
chan
error
),
// XXX no buf?
watchCancel
:
cancel
,
watchGroup
:
wg
,
},
nil
}
func
(
w
*
Watcher
)
Close
()
error
{
//fmt.Printf("watch: Close\n")
w
.
watchCancel
()
err
:=
w
.
watchGroup
.
Wait
()
close
(
w
.
Events
)
close
(
w
.
Errors
)
return
err
}
func
(
w
*
Watcher
)
Add
(
name
string
)
error
{
//fmt.Printf("watch: Add %s\n", name)
w
.
watchGroup
.
Go
(
func
(
ctx
context
.
Context
)
error
{
return
w
.
watch1
(
ctx
,
name
)
})
return
nil
}
func
(
w
*
Watcher
)
watch1
(
ctx
context
.
Context
,
name
string
)
(
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"watch %s"
,
name
)
fiPrev
,
err
:=
os
.
Lstat
(
name
)
if
err
!=
nil
&&
os
.
IsNotExist
(
err
)
{
err
=
nil
}
if
err
!=
nil
{
select
{
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
case
w
.
Errors
<-
err
:
return
err
}
}
//
for
{
if
err
:=
ctx
.
Err
();
err
!=
nil
{
return
err
}
fi
,
err
:=
os
.
Lstat
(
name
)
//fmt.Printf("watch %s: -> %v, %v\n", name, fi, err)
if
err
!=
nil
&&
os
.
IsNotExist
(
err
)
{
err
=
nil
}
if
err
!=
nil
{
select
{
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
case
w
.
Errors
<-
err
:
return
err
}
}
ev
:=
Event
{
Name
:
name
}
send
:=
false
switch
{
case
fiPrev
==
nil
&&
fi
==
nil
:
// nothing
case
fiPrev
==
nil
&&
fi
!=
nil
:
// created
ev
.
Op
=
Create
send
=
true
case
fiPrev
!=
nil
&&
fi
==
nil
:
// removed
ev
.
Op
=
Remove
send
=
true
default
:
// fiPrev != nil && fi != nil
if
fiPrev
.
ModTime
()
!=
fi
.
ModTime
()
{
ev
.
Op
=
Write
send
=
true
}
}
if
send
{
select
{
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
case
w
.
Events
<-
ev
:
// ok
}
}
time
.
Sleep
(
1
*
time
.
Millisecond
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment