diff options
author | We-unite <3205135446@qq.com> | 2024-08-06 19:45:04 +0800 |
---|---|---|
committer | We-unite <3205135446@qq.com> | 2024-08-06 20:02:34 +0800 |
commit | 2104c8ac26f320eacc3fa04d608843c3bf0fdc57 (patch) | |
tree | 79607526aab02b44ef86e311074c715b42461d69 /src/mongo.go | |
parent | f4655e64a1461c22ad7a3871375269915a743f40 (diff) | |
download | godo-2104c8ac26f320eacc3fa04d608843c3bf0fdc57.tar.gz godo-2104c8ac26f320eacc3fa04d608843c3bf0fdc57.zip |
Basically fixed info lost
As previous envisioned, the lost is caused by slow consumption. So
I make several changes:
- Delete all the mutexs, especially those in the mongodb. There seems
to have no necessity to use thread mutex, because execve, fork
and exit has no conflicton(really?)
- Insert all pid info into db, just ws what we do to file infos. So
we should filter out useful info from them, but this does works
to decrease lost infos.
Besides, the problem that recvfrom is always blocked may got solved.
When the machine is just started, it's blocked; but after i run the
C program to connect to ketlink connector and listen to it, both C
program and godo can recv infos well.
Also, left questions:
- Now i use many coroutine in 2nd and 3rd coroutines in the hope that
there will be less time to deal info and hear the kernel again as
quick as possible. But does it work? As we know, too much thread
will slower the program, because too frequent switch between threads
or processes.
- Sometimes the eventTable has bugs, when eoe is recvd, the pointer
in it is null. It may be out of thread confliction? But it's
unreasonable, there's only one place to delete the event, that's
just in eoe, after it's sent. Or the eoe info is got more than once?
- For some processes, when i look into /proc to find cwd and cmeline,
it has exited. If i go back to use audit for pid info, it will be hard
to distinguish between thread and process. Anyway, It doesn't matter
now, but what if?
Next step: Figure out the root fs of a docker, and its name.
Diffstat (limited to 'src/mongo.go')
-rw-r--r-- | src/mongo.go | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/src/mongo.go b/src/mongo.go index 764f877..1d9f74f 100644 --- a/src/mongo.go +++ b/src/mongo.go | |||
@@ -2,8 +2,6 @@ package main | |||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "context" | 4 | "context" |
5 | "fmt" | ||
6 | "sync" | ||
7 | "time" | 5 | "time" |
8 | 6 | ||
9 | "go.mongodb.org/mongo-driver/bson" | 7 | "go.mongodb.org/mongo-driver/bson" |
@@ -15,8 +13,6 @@ type mongoClient struct { | |||
15 | dbName, colName string | 13 | dbName, colName string |
16 | client *mongo.Client | 14 | client *mongo.Client |
17 | col *mongo.Collection | 15 | col *mongo.Collection |
18 | Mutex sync.Mutex | ||
19 | // Attention: 这把锁是否有必要? | ||
20 | } | 16 | } |
21 | 17 | ||
22 | func (mc *mongoClient) init(dbName, colName string) error { | 18 | func (mc *mongoClient) init(dbName, colName string) error { |
@@ -100,15 +96,3 @@ func (mc *mongoClient) Disconnect() error { | |||
100 | mc.colName = "" | 96 | mc.colName = "" |
101 | return nil | 97 | return nil |
102 | } | 98 | } |
103 | |||
104 | func (mc *mongoClient) GetLock() bool { | ||
105 | for i := 0; i < 200000; { | ||
106 | if !mc.Mutex.TryLock() { | ||
107 | i++ | ||
108 | } else { | ||
109 | return true | ||
110 | } | ||
111 | } | ||
112 | fmt.Printf("Die...\n") | ||
113 | return false | ||
114 | } | ||